Reputation: 1044
protected void GVVAC_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
DataTable dt = new DataTable();
int st = Convert.ToInt32(GVVAC.DataKeys[e.RowIndex].Values[0].ToString());
TextBox txtage1 = (TextBox)GVVAC.Rows[e.RowIndex].FindControl("txtage");
TextBox txtvaccinename1 = (TextBox)GVVAC.Rows[e.RowIndex].Cells[3].Controls[1];
TextBox txtadmin1 = (TextBox)GVVAC.Rows[e.RowIndex].Cells[4].Controls[1];
TextBox txtdose1 = (TextBox)GVVAC.Rows[e.RowIndex].Cells[5].Controls[1];
breederdailypl.Age = Convert.ToInt32(txtage1.Text.ToString());
breederdailypl.vaccine = txtvaccinename1.Text.ToString();
breederdailypl.admin = txtadmin1.Text.ToString();
breederdailypl.dose = txtdose1.Text.ToString();
breederdailypl.Snum = st;
dt = breederdailybal.updatevaccine(breederdailypl);
//chkHatchdetails = objhatcheryBAL.updateHatchMasterdet(objhatcheryPL);
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "UpdateDetails", "alert('Update Successful');", true);
GVVAC.EditIndex = -1;
grid();
}
When I edit the textbox and enter the new value, the new value does not appear in the textbox.
Upvotes: 0
Views: 301
Reputation: 10122
I am not sure about the code you have written. But what I guess is, initially when you bind your grid view, it is out side the if(!IsPostback) condition. So write the code inside !IsPostback condition as shown below :
If(!IsPostback)
{
grid();
}
If, it is not in !IsPostback condition then when you update your row it will first go to your page load, bind the grid again then it will go to your RowUpdating event. And because of this you will always get old value.
So I suggest to put your code to bind grid view in if(!IsPostback) condition.
Upvotes: 2
Reputation: 13381
for provide new value to textbox you must bind to grid new value, so
breederdailybal.updatevaccine(breederdailypl);
must update data that be get in
breederdailybal.GetBreederVaccination(breederdailypl);
in your case data probably not updated
Upvotes: 0