Skip to content

Instantly share code, notes, and snippets.

@martin0258
Created September 19, 2012 11:40
Show Gist options
  • Save martin0258/3749217 to your computer and use it in GitHub Desktop.
Save martin0258/3749217 to your computer and use it in GitHub Desktop.
Gridview Select Row Without Using SELECT Button
/// <summary>
/// Three TODO on using this:
/// 1. AutoGenerateSelectButton = "true" on GridView1
/// 2. Handle OnSelectedIndexChanged event of GridView1
/// 3. Set selectedrowstyle
/// </summary>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Style.Add("display", "none");
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
// HACK: user can select row by clicking anywhere at row
e.Row.Cells[0].Style.Add("display", "none");
e.Row.Style.Add("cursor", "pointer");
e.Row.Attributes["onclick"] = "__doPostBack('"+GridView1.UniqueID+"','Select$" + e.Row.RowIndex + "');";
e.Row.ToolTip = "點擊查看詳細或更改設定";
}
}
@martin0258
Copy link
Author

This is only for IE 5.5 and below version...

cursor: hand;

Use this instead (which is W3C standard)

cursor: pointer;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment