-------------------------------------------------------------------
GridView with clickable rows
If you need to have a GridView with rows that you can click on you will need to set the onClick event for each row.
Here is a code sample for the RowDataBound event of a GridView.
This examples pulls the value of cell 0 and appends it to the url.
protected void grd_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridView grid = (GridView)sender as GridView;
//Only format data rows
if (e.Row.RowType == DataControlRowType.DataRow)
{
string urlLink = “Link?number=” + e.Row.Cells[0].Text.ToString();
e.Row.Attributes["onClick"] = "location.href=’" + urlLink + "’";
}
}
-----------------------
Saturday, October 2, 2010
GridView with clickable rows
Saturday, October 02, 2010 Posted by Vikas SharmaLabels: GeneralTips n Tricks
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment