Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
All-Star
31334 Points
5415 Posts
Apr 23, 2012 01:14 PM|LINK
hi, you can get id like below
<asp:ButtonField HeaderText="Material" CommandName="Material" Text="Select" /> <asp:ButtonField HeaderText="Material1" CommandName="Material1" Text="Select" /> protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int index = ((e.CommandSource as Button).NamingContainer as GridViewRow).RowIndex; int Id = Convert.ToInt32(GridOracle.DataKeys[index].Value); switch (e.CommandName) { case "Material": Response.Write("Material"); break; case "Material1": Response.Write("Material1"); break; } }
if you statisfied with my ans. mark both the replies as answered one.
karthicks
All-Star
31334 Points
5415 Posts
Re: How to handle more than one commandfields in gridview
Apr 23, 2012 01:14 PM|LINK
hi, you can get id like below
<asp:ButtonField HeaderText="Material" CommandName="Material" Text="Select" /> <asp:ButtonField HeaderText="Material1" CommandName="Material1" Text="Select" /> protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int index = ((e.CommandSource as Button).NamingContainer as GridViewRow).RowIndex; int Id = Convert.ToInt32(GridOracle.DataKeys[index].Value); switch (e.CommandName) { case "Material": Response.Write("Material"); break; case "Material1": Response.Write("Material1"); break; } }if you statisfied with my ans. mark both the replies as answered one.
Karthick S