i have a asp buttonfield in a asp:gridview as follows
<asp:ButtonField ButtonType="Button" CommandName="Select" HeaderText="View" ShowHeader="True" Text="View" />
How do I access this element and give it some functionality(meaning, when i click the button, I want it to 开发者_StackOverflowdo something and not stare at me !)
thanks in advance
The CommandName value allows you to trap the command you wish to execute when the button is clicked. This event is raised by the GridView and can be trapped in the RowCommand event. A small snippet below:
void MyGridView_RowCommand(Object sender, GridViewCommandEventArgs e )
{
if(e.CommandName=="Select")
{
DoSomething();
}
}
精彩评论