Datagrid button column how to bind a function to a button?
Currently i have a datagrid view that displays names in the 1st columnnd in the 2nd column delete buttons.
This datagrid view already has bind data to a function so it can displays the names that are withint a xml file (first column is a hyperlink column).
But next i want to be able to delete the xml values that are in the first column. (by clicking on the delete button on the second column of it)
<name&g开发者_JAVA百科t;</name>
But how do i exactly bind a (delete) function to these buttons?
name1 btnDelete
name2 btnDelete
etc...
Thanks in advance.
For datagrid you have handle the ondeletecommand event, see below.
<asp:DataGrid runat="server" ID="dg" ondeletecommand="dg_DeleteCommand">
then define the event handler in your code behind .. see below.
protected void dg_DeleteCommand(object source, DataGridCommandEventArgs e)
{
}
the DataGridCommandEventArgs has all the properties you'll need to check including e.CommandName etc
Hope this helps.
I don't know about datagrid but in gridView I use
set button's command name and use GridView's RowCommand Event.
if(e.commandName == "delete")
//ur code;
Template field
for default delete of GridView use
girdViewRowDeleting
Hope it will help..
精彩评论