473,322 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

32
Hi,

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.

Thanks
Janet
Jun 15 '07 #1
2 7522
kenobewan
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
dixonjm
32
That's great - sounds exactly what I need.

Many thanks
Janet
Jun 18 '07 #3

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

Similar topics

1
by: Bruno Alexandre | last post by:
in the form I have: <asp:TextBox ID="fAte" Runat="server" Width="80px">31-01-2004</asp:TextBox> in the GridView I have: <asp:HyperLinkField DataTextField="nC" HeaderText="nome Colab"
0
by: shellyshao | last post by:
Hi everyone, I have tried looking everywhere to fix this. Any help would be appreciated. Situation: Developing a web application for company intranet. Application allows users to download...
8
by: =?Utf-8?B?TWlrZSBSYW5k?= | last post by:
I am trying to get a list of files from a specified directory using the System.IO namespace classes, and then use that list as the datasource for a GridView. I have been able to do this...
7
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi all! I have a gridview inside a datagrid (nested) for which (gridview) the rowcommand is not raised in order to delete a row from the grid! I also tried OnRowCommand="method", didn't work...
8
by: Jeff | last post by:
ASP.NET 2.0 I'm wondering how to set the color of a visited HyperLinkField (the link text) in a GridView?? Here is the markup of the HyperLinkField I have problems with: <asp:HyperLinkField...
0
by: bodamithun | last post by:
Hi all, For some weird reason my hyperlinkfield does not work. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" > ...
1
by: boevermann | last post by:
I prototyped an html table that has a hyperlink that pops a window showing a map of the entry from the that table. The link looks like this: <a href="authenticate.asp"...
1
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
Hello: I have a hyperlink field in my gridview that redirects to a new page. I would like to set a session variable to a value from the grid row where the hyperlink was clicked before the...
4
by: Jeff | last post by:
Hi asp.net 2.0 I'm trying to implement a HyperLinkField into my GridView.. The SqlDataSource returns a field which is paths to files (each row in the GridView should have link to a file). ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.