[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 980
  • Last Modified:

aspx GridView get values before update

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?
  • 3
1 Solution
tonelm54Author Commented:
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

tonelm54Author Commented:
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

tonelm54Author Commented:
I belive the line 'MsgBox(GridView1.FindControl("TextBox1"))' should display my new value Ive entered into the row, but instead just fails.
You should use like

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now