get primary key value [modified]
-
hi sir please help me i want the primary key column value on gridview_rowcommand() please send me code if possible thanx hi sir i am using following code: Lock protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if ((e.CommandName).ToString() == "lock_user") { int index = Convert.ToInt32(e.CommandArgument); string userid = GridView1.Rows[index].FindControl("UserIdName").ToString(); WebMsgBox.Show(userid); } } but it gives blank messagebox and i want that userid.
modified on Friday, July 10, 2009 6:35 AM
-
hi sir please help me i want the primary key column value on gridview_rowcommand() please send me code if possible thanx hi sir i am using following code: Lock protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if ((e.CommandName).ToString() == "lock_user") { int index = Convert.ToInt32(e.CommandArgument); string userid = GridView1.Rows[index].FindControl("UserIdName").ToString(); WebMsgBox.Show(userid); } } but it gives blank messagebox and i want that userid.
modified on Friday, July 10, 2009 6:35 AM
refer : GridView all in one[^]
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
hi sir please help me i want the primary key column value on gridview_rowcommand() please send me code if possible thanx hi sir i am using following code: Lock protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if ((e.CommandName).ToString() == "lock_user") { int index = Convert.ToInt32(e.CommandArgument); string userid = GridView1.Rows[index].FindControl("UserIdName").ToString(); WebMsgBox.Show(userid); } } but it gives blank messagebox and i want that userid.
modified on Friday, July 10, 2009 6:35 AM
vikas shukla wrote:
please send me code if possible
What have you tried so far? A simple Google search would have gave you a nice idea.
void mygridview_RowCommand(Object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);GridViewRow row = ContactsGridView.Rows\[index\]; //use the index of the column to retrieve the value //for eg //string thirdcolumn = row.Cells\[2\].Text; //...do whatever
}
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
hi sir please help me i want the primary key column value on gridview_rowcommand() please send me code if possible thanx hi sir i am using following code: Lock protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if ((e.CommandName).ToString() == "lock_user") { int index = Convert.ToInt32(e.CommandArgument); string userid = GridView1.Rows[index].FindControl("UserIdName").ToString(); WebMsgBox.Show(userid); } } but it gives blank messagebox and i want that userid.
modified on Friday, July 10, 2009 6:35 AM
asp:TemplateField <ItemTemplate> <asp:Button runat="server" CommandName="BtnUpdate" CommandArgument='<% Eval("PrimaryKeyField") %>' /> </ItemTemplate> </asp:TemplateField>
himanshu