Hi all! I'm using visual studio 2008 and i'm having trouble extracting the data out from the controls in the gridview. This is how it's supposed to work: user clicks on edit button, the selected row would change to textboxes and dropdownlist for them to choose. Once edited, they click on update and it will be updated. However, when i click on update, the rowupdating method is executed twice in a row and the data retrieve would be the original data instead of the edited ones. For example, if the data in the textbox is A and i change it to B, when i click on update, it would take the A data. Whereas for dropdownlist, it would read the 1st list item.
Below is the code:
<EditItemTemplate>
<asp:TextBox ID="txtDate" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "date") %>'></asp:TextBox>
</EditItemTemplate>
This is executed in the rowupdating method:
Dim ddlduty As DropDownList
Dim txtDate As TextBox
Dim txtHrs As TextBox
Dim duty As String
Dim dutyDate As Date
Dim hrs As Integer
Dim row As GridViewRow = gvTimesheet.Rows(e.RowIndex)
ddlduty = CType(row.FindControl("ddlDuties"), DropDownList)
txtDate = CType(row.FindControl("txtDate"), TextBox)
txtHrs = CType(row.FindControl("txtHrs"), TextBox)
duty = ddlduty.SelectedValue
dutyDate = CType(txtDate.Text, Date)
hrs = CType(txtHrs.Text, Integer)