Meer Ahmed

Meer Ahmed

  • NA
  • 4
  • 1.6k

Losing ViewState in Dynamic Controls adding.

Mar 2 2015 6:33 AM
I am working with Dynamic/Custom control,
my Controls contain an accordion, inside this accordion i have Gridview, The Gridview has events Edit, Update.
When i Edit a Row and change a column value an press update, i did not get new column value in Updating event. I get old value of that column.
my Code is here.

<asp:TemplateField HeaderText="Order" HeaderStyle-ForeColor="White" HeaderStyle-BorderColor="Black">
                                    <EditItemTemplate>
                                        <center>
                                            <asp:TextBox ID="txt" CssClass="Order_txt" runat="server" Text='<%# bind("value") %>'></asp:TextBox></center>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="lbl" runat="server" Text='<%# bind("value") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="90px" />
                                </asp:TemplateField>

In Code behind on GridView_Rowupdating event.

Dim valueAs String = CType(GV_Parameter.Rows(RowIndex).FindControl("txt"), System.Web.UI.WebControls.TextBox).Text

i get old value as i enter new value in text box.