asp.net gridview doubleclick a row
时间: 2024-05-08 17:16:32 浏览: 121
As an AI language model, I cannot perform the action of double-clicking a row in an ASP.NET GridView, but I can provide you with the following steps to achieve this functionality:
1. Add an event handler for the GridView RowCreated event.
2. In the event handler, add the following code to attach a client-side double-click event to the row:
```
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["ondblclick"] = ClientScript.GetPostBackClientHyperlink(GridView1, "Select$" + e.Row.RowIndex);
}
}
```
3. Add an event handler for the GridView SelectedIndexChanged event.
4. In the event handler, add the following code to retrieve the data from the selected row and perform the desired action:
```
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
// Retrieve data from the row here and perform desired action
}
```
Note: The GridView must have the SelectCommand property set and the AutoGenerateSelectButton property set to true for this to work.
阅读全文