I have a grid view which is populated from a database.
I need to make it so that each of the cells in a particular column, when clicked will link through to a second page and pass the cell’s text value as a query string (ie link to http://mysite.com/page.aspx?CellText=‘blah blah blah’). Sounds simple I know but I just can’t figure it out!
This is what my page looks like at the moment:
<asp:GridView id="gdvTargets"
runat="server"
AutoGenerateEditButton="true"
OnRowEditing="gdvTargets_RowEdit"
OnRowUpdating="gdvTargets_RowUpdating"
OnRowUpdated="gdvTargets_RowUpdated"
OnRowCancelingEdit="gdvTargets_RowCancelingEdit"
cssClass="grid"
>
<HeaderStyle CssClass="GridHeader"></HeaderStyle>
And my c# code behind it:
protected void Page_Load(object sender, EventArgs e)
{
year = Request.QueryString["YearSelector"];
targetType = Request.QueryString["TargetType"];
gdvTargets.DataSource = this.Ets.Api.Util.Db.GetDataTable("EXEC sp_getTargets " + year + ", " + targetType).Return;
gdvTargets.DataBind();
}
This results in a table which looks something like this:
ID System Target 1 Target 2 Target3 Target 4
0 ALL 10 20 15 10
2 Machine1 4 7 7 7
5 Xfgb 45 6 13 8 3
I would like the system column to be clickable and link through to a new page but take the name of the system with it. Hope this makes sense! Thanks for your help 😀
What you can do is the following:
Replace 0 by your column index