I was just testing if I will get the changed value out of the textbox when updating with no luck. I just cant get the new value. What am I doing wrong? I have tried numerous things. And this is the latest one. How can I get the updated new value to my label? When I click edit on the grid and change the value of the textbox and click update the label will just display the original value of the textbox.
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
bindgrid();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = GridView1.Rows[e.RowIndex];
Label1.Text = ((TextBox)(GridView1.Rows[GridView1.EditIndex]).Cells[2].Controls[0]).Text;
GridView1.EditIndex = -1;
bindgrid();
}
I think when you push update link Gridview
is binding again before taking new value. You must use if(!IsPostBack)
before GridView.DataBind()
.
just set Enableviewstate property to false of gridview you can get new value.
<asp:GridView runat="server" EnableViewState="False" ID="GridView6" AutoGenerateColumns="false" Width="100%"
EmptyDataText="No Record Found" AllowPaging="false" PageSize="10" OnPageIndexChanging="ChangePage"
OnRowCommand="RowCommand" OnRowDataBound="GridView6_RowDataBound" >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With