Created
September 19, 2012 11:40
-
-
Save martin0258/3749217 to your computer and use it in GitHub Desktop.
Gridview Select Row Without Using SELECT Button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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 = "點擊查看詳細或更改設定"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is only for IE 5.5 and below version...
Use this instead (which is W3C standard)