Hi,
I have the following code:
<asp:GridView ID="MyGridView" runat="server" AllowPaging="true" PageSize="30" AutoGenerateColumns="False"
AllowSorting="true">
<Columns>
<asp:TemplateField HeaderText="Industry ID" ItemStyle-Width="150px" ItemStyle-HorizontalAlign="Center"
SortExpression="ID">
<ItemTemplate>
<asp:Label ID="IDLabel" runat="server" Text='<%#Eval("ID") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID=" IDLabel " runat="server" Text='<%#Eval("ID") %>' />
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="EnterLabel" runat="server" Text="Please, enter the new name: " />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name" ItemStyle-HorizontalAlign="Center" SortExpression="Name">
<ItemTemplate>
<asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="EditNameTextBox" runat="server" Text='<%#Bind("Name") %>' />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="NewNameTextBox" runat="server" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:LinkButton ID="EditLinkButton" runat="server" Text="Edit" CommandName="Edit" />
<asp:LinkButton ID="DeleteLinkButton" runat="server" Text="Delete" OnClientClick="javascript:if(!confirm('Are you sure you want to delete the selected use?'))return false;"
OnClick="DeleteLinkButton_Click" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="UpdateLinkButton" runat="server" Text="Update" CommandName="Update" />
<asp:LinkButton ID="CancelLinkButton" runat="server" Text="Cancel" CommandName="Cancel" />
</EditItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="AddLinkButton" Text="Add" OnClick="AddLinkButton_Click" runat="server" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
In the rowUpsating event, in code behind, I have the following:
Protected Sub myGridView_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles myGridView.RowUpdating
Dim row As GridViewRow = myGridView.Rows(e.RowIndex)
Dim EditNameTextBox As TextBox = row.FindControl("EditNameTextBox")
Dim name As String = EditNameTextBox.Text
...
End Sub
Suppose Name is initially ASP.NET and I need to change to HTML. The problem I'm having is: when I do: EditNameTextBox.Text instead of getting the new name I just type (in this case, HTML), it's getting the old one (ASP.NET). I cannot see what is wrong. Does anyone have suggestions?
Thanks,
Ana