c# gridview row click
- by Martijn
When i click on a row in my gridview, i want to go to a other page with the id i get from the database.
In my RowCreated event i have the following line:
e.Row.Attributes.Add("onClick", ClientScript.GetPostBackClientHyperlink(this.grdSearchResults, "Select$" + e.Row.RowIndex));
To prevent error messages i have this code:
protected override void Render(HtmlTextWriter writer)
{
// .NET will refuse to accept "unknown" postbacks for security reasons. Because of this we have to register all possible callbacks
// This must be done in Render, hence the override
for (int i = 0; i < grdSearchResults.Rows.Count; i++)
{
Page.ClientScript.RegisterForEventValidation(new System.Web.UI.PostBackOptions(grdSearchResults, "Select$" + i.ToString()));
}
// Do the standard rendering stuff
base.Render(writer);
}
My question is, how can i give a row a unique id (from the DB) and when i click the row, another page is opened (like clicking on a href) and that page can read the id.
Thnx