Reputation: 1599
What I am trying to do is have a grid view with 3 "select" and I renamed them to edit , delete and details
and each one should redirect to a certain page
my question , how I can know which column or "Select" the user clicked
Thanks
Upvotes: 2
Views: 3277
Reputation: 629
string commandName = e.CommandName.ToString().Trim();
GridViewRow row = GridView1.Rows[Convert.ToInt32(e.CommandArgument)];
switch (commandName)
{
case "showName":
LClickName.Text = "You Clicked Show Name Button : \"" + row.Cells[1].Text + "\"";
break;
case "EditName":
LClickName.Text = "You Clicked Edit Name Button : \"" + row.Cells[1].Text + "\"";
break;
default: break;
}
Here is a sample for Multiple select Button in One Gridview
Multiple Select Button In One Gridview
Upvotes: 0
Reputation: 69270
Set the CommandName
property of your buttons. Then add an event handler for the RowCommand
event of the gridview:
protected void MyGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch(e.CommandName)
{
case "SomeCommand":
Response.Redirect("SomePage.aspx");
break;
case "OtherCommand":
Respone.Redirect("OtherPage.aspx");
}
Upvotes: 1