Click here to Skip to main content
15,898,851 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
XML
<EditItemTemplate>
                    <asp:TextBox ID="txtDate" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "date") %>'></asp:TextBox>
                </EditItemTemplate>


This is executed in the rowupdating method:
VB
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)
Posted
Updated 11-Oct-10 17:34pm
v2

1 solution

 
Share this answer
 
Comments
specialu 25-Oct-10 12:25pm    
the link is not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900