Here is an extract of some code on a webform. The code is within a GridView called gvContactSummary.
when you click the edit link that appears a bit further across the grid the 'EditItemTemplate' is displayed and the Textbox with ID="txtValue" appears - with the correct data to edit displayed in it.Code:<asp:TemplateField HeaderText="Details"> <ItemTemplate> <asp:HyperLink ID="hlDetails" runat="server"></asp:HyperLink> <asp:Label runat="server" ID="lblDescription" Text="" ToolTip='<%# Eval("Description")%>' /> </ItemTemplate> <EditItemTemplate> <asp:TextBox runat="server" ID="txtValue" Text='<%# Eval("Details")%>' CssClass="NormalTextbox" Width="320px" /> </EditItemTemplate> </asp:TemplateField>
If I change the data in the text box and click Update this happens ... (just an extract)
Now I know the update is happening correctly because if I hard code the value of the text box 'txtValue' this hard-coded value is then written to the database when Update is clicked.Code:DataAccess da = new DataAccess(); GridViewRow row = gvContactSummary.Rows[e.RowIndex]; Label AIID = (Label)row.FindControl("AIID"); Label LocationID = (Label)row.FindControl("LocationID"); Label Type = (Label)row.FindControl("lblType"); TextBox txtVal = (TextBox)row.FindControl("txtValue"); if (AIID.Text != "0") { //Update Addn info ID string Description = ""; da.UpdateContactAddnContactInfo(Convert.ToInt32(AIID.Text), txtVal.Text, Description); }
But, when it is not hardcoded - ie. when the textbox contains a value from the database (in this case a phone number) then ...
If I click Edit- the textbox appears and I remove the existing phone number, enter a new one and click Update. But the value of txtVal.Text is showing the number before I edited it.
Can anyone explain why, when the Update link is clicked, txtVal.Text does not contain the current value of the text box txtValue - it contains the original value.
Thanks for any help. Spent all afternoon on this and got nowhere!




Reply With Quote