469,364 Members | 2,332 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,364 developers. It's quick & easy.

how to raise an event from a HyperLinkField in a gridview (ASP.NET C# Web App)


Just wondering if there is a way to do the above, as I need to check some values on from the gridview before it uses the DataNavigateUrlFormatString to post to another page.

Jun 15 '07 #1
2 7396
4,871 Expert 4TB
I would convert your Bound field to a Template Field with a LinkButton to display value rather than using a HyperLinkField.

You can then set the CommandName of the link button - you could use Select in which case you can use the SelectedIndexChanged event. If you use a different CommandName use the RowCommand event and test e.CommandName to check which command (and therefore column) raised the event.

If you use the SelectedIndexChanged event it's easy to get the row index e.g. GridView1.SelectedIndex

If you use RowCommand there are various ways to retrieve the rowindex, I generally use the RowDataBound event of the GridView and FindControl to find the linkbutton, then set button's CommandArgument to the RowIndex. e.CommandArgument is then available in the RowCommand event. HTH.
Jun 16 '07 #2
That's great - sounds exactly what I need.

Many thanks
Jun 18 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Bruno Alexandre | last post: by
reply views Thread by shellyshao | last post: by
8 posts views Thread by =?Utf-8?B?TWlrZSBSYW5k?= | last post: by
7 posts views Thread by =?Utf-8?B?cGF0cmlja2RyZA==?= | last post: by
1 post views Thread by =?Utf-8?B?UGV0ZXI=?= | last post: by
4 posts views Thread by Jeff | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.