i think this maybe an easy one…
I have a Gridview, bound to a dataSource with this query:
select userid, name, phone from users
I need to change the content of the Name cell to a link, like so:
<a href="http://www.domain.com/page.aspx?userid=12345">User's Name</a>
so OnRowDataBound i’m doing this:
e.Row.Cells[1].Text = "<a href=\"http://www.domain.com/page.aspx?userid=\" + e.Row.Cell[0].Text + "\">" + e.Row.Cells[1].Text + "</a>";
It all works fine this way. My problem is that i don’t want to display the UserId column in the Gridview, but when i attribute it (asp attribute or server-side) Visible="false" to the BoundField UserId, i can’t capture it’s value to build the Name Cell.
Thanx for your help
Make your gridView to use template items instead of simple grivdiew column.
You can find a nice intro Here