template column in GridView !!??
-
Dears Hi, Im using VS 2005 and Instead of using SELECT in GridView I need to use on of GridView column as link to anther page and pass values to second page I use template column but how I can pass parameter and specify the link I use the following but is not working
href ="~/xyz/page2.aspx?id=<%# DataBinder.Eval(Container.DataItem, "ID") %>">
thanks.... -
Dears Hi, Im using VS 2005 and Instead of using SELECT in GridView I need to use on of GridView column as link to anther page and pass values to second page I use template column but how I can pass parameter and specify the link I use the following but is not working
href ="~/xyz/page2.aspx?id=<%# DataBinder.Eval(Container.DataItem, "ID") %>">
thanks....You can put Label in Template column. In event RowDataBound of GridView put this code : protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Label lbl = (Label)e.Row.Cells[TemplateCellNumber].Controls[1]; lbl.Attributes.Add("onclick", string.Format( "window.location = 'url?{0}={1}'",param1, param2)); lbl.Style.Add("cursor", "pointer"); } }
and they all died