aspx GridView get values before update

Posted on 2009-04-30
Last Modified: 2012-08-14
Im looking for a way to use a GridView, but actually control the update command more.

What Id like to be able to do is once the 'update' is clicked in an editable row, before the update is commited to call a function and be able to query the textboxes in the editable row.

Any ideas?
Question by:tonelm54

    Author Comment

    ASPx Code
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:personalConnectionString %>" 
                DeleteCommand="select uuid();" 
                InsertCommand="select uuid();" 
                ProviderName="<%$ ConnectionStrings:personalConnectionString.ProviderName %>" 
                SelectCommand="Select `priID`, `tt` from `test`" 
                UpdateCommand="select uuid();">
            <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
                AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                    <asp:BoundField DataField="priID" HeaderText="priID" SortExpression="priID" />
                    <asp:TemplateField HeaderText="tt" SortExpression="tt">
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("tt") %>'></asp:TextBox>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("tt") %>'></asp:Label>
                    No DATA

    Open in new window


    Author Comment

    VB Code
    Partial Class _Default
        Inherits System.Web.UI.Page
        Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
            If e.CommandName = "Update" Then
            End If
        End Sub
    End Class

    Open in new window


    Author Comment

    I belive the line 'MsgBox(GridView1.FindControl("TextBox1"))' should display my new value Ive entered into the row, but instead just fails.
    LVL 14

    Accepted Solution

    You should use like

    TryCast(e.Row.FindControl("TextBox1"), TextBox).Text

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now