출처: http://www.ezzylearning.com/tutorial.aspx?tid=5066444

protected void GridView_List_RowCommand(object sender, GridViewCommandEventArgs e)
{
           
            string currentCommand = e.CommandName;
            int currentRowIndex = Int32.Parse(e.CommandArgument.ToString());
            string ProductID = GridView_List.DataKeys[currentRowIndex].Value;

            Label1.Text = "Command: " + currentCommand;
            Label2.Text = "Row Index: " + currentRowIndex.ToString;
            Label3.Text = "Product ID: " + ProductID;   

}


 


<asp:ButtonField ButtonType="link" CommandName="ProductName" 
         DataTextField="ProductName" HeaderText="Name"
         SortExpression="ProductName" />



Posted by 노을지기