i have 2 select Button
controls in a GridView
like this
<asp:datagrid style="Z-INDEX: 0" id="DataGrid1" runat="server" Width="936px"
HorizontalAlign="Justify" CellPadding="5" AutoGenerateColumns="False"
AllowCustomPaging="True" AllowSorting="True">
<asp:ButtonColumn Text="Button 1" CommandName="Select">
<HeaderStyle Width="5%"></HeaderStyle>
</asp:ButtonColumn>
<asp:ButtonColumn Text="Button 2" CommandName="Select">
<HeaderStyle Width="5%"></HeaderStyle>
</asp:ButtonColumn>
</asp:datagrid>
In code behind in DataGrid1_SelectedIndexChanged
how can i detect which button user has clicked
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(//user click button 1) {}
else // user clicked button 2 {}
}
thank for your answer
To response to row commands as in your case, you need to handle GridView
RowCommand event.
The GridView
SeletedIndexChanged event is using to capture selection changing only. That means, if you pressed a command row on an already selected row, the SelectedIndexChanged
is not going to fired.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.