Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

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?
Avatar of tonelm54
tonelm54

ASKER

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:SqlDataSource>
        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
            AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="priID" HeaderText="priID" SortExpression="priID" />
                <asp:TemplateField HeaderText="tt" SortExpression="tt">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("tt") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("tt") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                No DATA
            </EmptyDataTemplate>
        </asp:GridView>

Open in new window

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
            MsgBox(GridView1.FindControl("TextBox1"))
        End If
    End Sub
End Class

Open in new window

I belive the line 'MsgBox(GridView1.FindControl("TextBox1"))' should display my new value Ive entered into the row, but instead just fails.
ASKER CERTIFIED SOLUTION
Avatar of GiftsonDJohn
GiftsonDJohn
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial