Turn headertext in a GridView into a link to open a new window


In the Row_Created event of GridView, add this:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.Header)

{

foreach (TableCell cell in e.Row.Cells)

{

if (cell.Text == "Wr")

{

cell.Text =

"<a href=\"myNewpage.aspx?mycode=wr\" onclick =\"window.open(this.href, ‘popupwindow’, ‘width=600,height=270,scrollbars,resizable’); return false;\">Wr</a>";

}

}

}

}

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s