Data not updated in GridView

partha.majumdar

Active member
Joined
Aug 13, 2006
Messages
33
Location
Kolkata
Programming Experience
10+
Dear Sir,

I have a GridView defined as follows.
==============
<asp:GridView ID="dgMain" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="TeamCode" HeaderText="Code" ReadOnly="True" />
<asp:TemplateField HeaderText="Name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("TeamName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("TeamName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
<asp:CommandField ShowSelectButton="True" />
</Columns>
</asp:GridView>
==================

It is fetching data correctly. However, when I click EDit and change the data and then press Update, the value is not updated. When I debug, I find that the value before the change is being fetched.
The code behind is as follows:
===================

Private Sub dgMain_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles dgMain.RowUpdating
Dim strCode As String = dgMain.Rows(e.RowIndex).Cells(0).Text

Dim strName As String = CType(dgMain.Rows(e.RowIndex).FindControl("TextBox1"), TextBox).Text
dtblMain.Select("TeamCode = '" + strCode + "'")(0)("TeamName") = strName

dgMain.EditIndex = -1
dgMain.DataBind()
End Sub
==================

Please help.

Regards,
Partha
 
Back
Top