not updating data... [Resolved]

Posted by avijit111-12747 under C# on 11/24/2011 | Points: 10 | Views : 874 | Status : [Member] | Replies : 4
dear all,
I am getting problem in gridview.After edit text field when i am clicking on update command ,event is occurred but not getting update.I checked sql procedure its working fine something going wrong in code-behind. i am sending code pls check and help me.
/************************************************************************************************************************/
protected void grdDetaildata_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string sCompany = "";
string sEmpCode = "";
//string ssr_no = "";


if (Request.QueryString["comcode"] != null && Request.QueryString["comcode"].ToString() != "")
{
sCompany = Request.QueryString["comcode"].ToString();

}
if (Request.QueryString["empcode"] != null && Request.QueryString["empcode"].ToString() != "")
{

sEmpCode = Request.QueryString["empcode"].ToString();
}
int sr_no = Int32.Parse(grdDetaildata.DataKeys[e.RowIndex].Value.ToString());

string sResult = "";

sResult = sr_no.ToString();
TextBox txtsrno = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txtsrno");
TextBox txtexplosives_names1 = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txtexplosives_names1");
TextBox txttoday_data1 = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txttoday_data1");
TextBox txttill_data1 = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txttill_data1");
TextBox txtmeasures1 = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txtmeasures1");
TextBox txtcode_no1 = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txtcode_no1");
TextBox txtop_stock1 = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txtop_stock1");
TextBox txtop_stock_dt1 = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txtop_stock_dt1");
TextBox txtreceived_stock1 = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txtreceived_stock1");
TextBox txtclosing_stock1 = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txtclosing_stock1");
TextBox txtmeasures2 = (TextBox)grdDetaildata.Rows[e.RowIndex].FindControl("txtmeasures2");


Library lib = new Library();

try
{

sResult = lib.UpdateData(Convert.ToInt32(txtsrno.Text.Trim()), txtexplosives_names1.Text.Trim(),
txttoday_data1.Text.Trim(), txttill_data1.Text.Trim(), txtmeasures1.Text.Trim(), txtcode_no1.Text.Trim(),
txtop_stock1.Text.Trim(),txtop_stock_dt1.Text.Trim(), txtreceived_stock1.Text.Trim(), txtclosing_stock1.Text.Trim(), txtmeasures2.Text.Trim());

if (sResult != null)
{
lblMsg.Text = "Record Updated Successfully";
}
else
{
lblMsg.Text = "Record Updated Failed";
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message.ToString();

}
finally
{
lib = null;
}

grdDetaildata.EditIndex = -1;
this.filldetaildata();


}

/***********************************************************************************************************************/




Responses

Posted by: Nitesh.luharuka on: 11/25/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
In page_load, have you done data binding using below:

if(! IsPostBack)

this.filldetaildata();


Nitesh Luharuka
http://www.niteshluharuka.com

avijit111-12747, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: avijit111-12747 on: 11/25/2011 [Member] Starter | Points: 25

Up
0
Down
yap but my question was to not updating you are saying for fetching data after update..........Actually my code was completely ok i did mistake somewhere...sorry to all.

avijit111-12747, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 11/25/2011 [Member] Starter | Points: 25

Up
0
Down
If your problem got resolved then please mark as resolved .

Regards,
Sunil

avijit111-12747, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Arefin on: 11/29/2011 [Member] Starter | Points: 25

Up
0
Down

If your problem got resolved then please mark as resolved . It will save time for us.
happy coding.

Thanks,
Arefin

avijit111-12747, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response