Not Updating value in gridview

Posted by Saritha.rajeshkumar under C# on 5/29/2011 | Points: 10 | Views : 1930 | Status : [Member] | Replies : 4
hi,
In gridview the value is not updated.
here is my code




protected void GridViewCdetails_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridViewCdetails.EditIndex = -1;
GridViewCdetails.DataSource = subcat.ShowSubcategory();
GridViewCdetails.DataBind();
}

protected void GridViewCdetails_RowEditing(object sender, GridViewEditEventArgs e)
{
GridViewCdetails.EditIndex = e.NewEditIndex;
GridViewCdetails.DataSource = subcat.ShowSubcategory();
GridViewCdetails.DataBind();
}

protected void GridViewCdetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)GridViewCdetails.Rows[e.RowIndex];
Label lbl = (Label)row.FindControl("Lblid");

TextBox sname = (TextBox)row.FindControl("EdTxtSubcategoryName");
TextBox sdesc = (TextBox)row.FindControl("EdTxtDescp");
DropDownList priority = (DropDownList)row.FindControl("EdPriority");
TextBox cname = (TextBox)row.FindControl("EdTxtCategoryid");

subcat.subcategoryid = Convert.ToInt32(lbl.Text);
subcat.SubCategoryName = sname.Text.Trim();
subcat.SubCategoryDesc = sdesc.Text.Trim();
subcat.SubCategorypriority = priority.Text.Trim();
subcat.categoryid = int.Parse(cname.Text);
subcat.UpdateSubcategory();
GridViewCdetails.EditIndex = -1;
GridViewCdetails.DataSource = subcat.ShowSubcategory();
GridViewCdetails.DataBind();
}




Responses

Posted by: Sheesh on: 5/29/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
Could you please tell me the error message, & on which line it shows the error message..

Thanks
Regards

Thanks
Regards

Saritha.rajeshkumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saritha.rajeshkumar on: 5/29/2011 [Member] Starter | Points: 25

Up
0
Down
Iam not getting the Error and not Updating the row

Saritha.rajeshkumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lokesh76 on: 5/29/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Please check with you "GridViewCdetails_RowUpdating" event its fired proper or not if its not fired proper please refer below link...

http://stackoverflow.com/questions/966819/gridview-rowupdating-event-not-firing



Thanks
Lokesh Kumar

Saritha.rajeshkumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 5/30/2011 [Member] Starter | Points: 25

Up
0
Down
do onething

public void bind()
{
sqldataadapter da=new sqldataadapter("select * from tname",cn);
datatable dt=new datatable();
da.fill(dt);
gridview1.datasource=dt;
gridview1.databind();
}
now call it in gridview roweditcancel rowediting ..... events

Thanks&Regards
LakshmiNarayana Nalluri.

Saritha.rajeshkumar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response