1./////////// HTML
3.////////// CS
<asp:GridView ID="GridView1" runat="server" DataKeyNames="ID" AutoGenerateColumns="false"
OnRowDataBound="GridView1_RowDataBound" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:BoundField DataField="Name"
HeaderText="Name"
/>
<asp:BoundField DataField="Country"
HeaderText="Country"
ItemStyle-Width="150"
/>
<asp:CommandField SelectText="Select"
ShowSelectButton="true"
Visible="false"
/>
</Columns>
</asp:GridView>
2.//////////// Event on page directory
<%@ Page
Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default"
EnableEventValidation="false"
%>
3.////////// CS
protected void
GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("ondblclick",
"__doPostBack('GridView1','Select$"
+ e.Row.RowIndex + "');");
e.Row.Attributes["style"] =
"cursor:pointer;";
}
}
protected void
GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow gvRow = GridView1.Rows[index];
}
No comments:
Post a Comment