views:

253

answers:

2

Hi all,

is it possible to create a template field with link option using codebehind.

A: 

Yes! Append handler OnRowDataBound

MyRowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
            e.Row.Controls.Add(new MyControl(...
Dewfy
how to add this field using codebehind<a onclick='javascript:window.open("<%# "sample.aspx?ID="+ Eval("ID")%>","",",width=280,height=200,target=_Blank")' href="#"> Details</a>
var hl = new HyperLink();hl.Attributes["onclick"] = "javascript:window" + DataBinder.Eval(e.Row.DataItem, "ID")... e.Row.Controls.Add(hl)
Dewfy