Updating rows in gridview [Resolved]

Posted by Maheshvishnu under ASP.NET on 9/13/2012 | Points: 10 | Views : 3915 | Status : [Member] | Replies : 4
I bind employee table to gridview
on rowupdating event i wrote the following
{
string EmpId=gridview1.Rows[e.rowindex].cells[0].text;

string EmpName=gridview1.Rows[e.rowindex].cells[1].text;

string EmpAge=gridview1.Rows[e.rowindex].cells[2].text;

but i am not getting EmpId,EmpName,EmpAge values


suggest some solution for this

Thanks in advance

mahesh


Responses

Posted by: Kotra.Ramakrishna on: 9/17/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

Mahesh please try blow code.

//if your using BoundField
TextBox txtEmpId = (GridView1.Rows[e.RowIndex].Cells[0].Controls[0]) as TextBox;

// If your using template field
TextBox txtEmpId = GridView1.FindControl("txtEmpId") as TextBox;

Thanks & Regards
Ramakrishna.k

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

Posted by: Hariinakoti on: 9/13/2012 [Member] Starter | Points: 25

Up
0
Down
hi mahesh,
u can give index values properly
string EmpId=gridview1.Rows[e.rowindex[0]].text;
try like this

Thanks & Regards
Hari

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

Posted by: Hemanth.Sutapalli on: 9/13/2012 [Member] Starter | Points: 25

Up
0
Down
hi Mahesh,
Try this Code also,
GridViewRow row = gridview1.Rows[e.RowIndex]  as GridViewRow;

TextBox txt1 = row.FindControl("Write Your TextBoxID for EmpId") as TextBox;
TextBox txt2 = row.FindControl("Write your TextBoxID for EmpName") as TextBox;
TextBox txt3 = row.FindControl("Write Your TextBoxid for EmpAge") as TextBox;
string EmpId = txt1.Text;
string EmpName = txt2.Text;
string EmpAge = txt3.Text;


Thanks& Regards,
S.Hemanth

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

Posted by: Jayakumars on: 9/17/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
try this update your Datatable.


System.Data.DataTable dt = new System.Data.DataTable();
dt.Rows[0].BeginEdit();
dt.Rows[0]["Ename"] = "Jesus";
dt.Rows[0].EndEdit();


Mark as Answer if its helpful to you

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

Login to post response