.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Is it possible to have a click event handler on a HyperLinkField in a gridview?

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :ASP.Net

Hi everyone-

I'd like to have a panel turn on when the user clicks on any link in the link column of this bound gridview.  I don't see how to set up the handler in the code behind. Is it possible?

<asp:GridView ID="GridView5" runat="server" AutoGenerateColumns="False" Width="710px" GridLines="None"> <Columns> <asp:BoundField DataField="clientComment" HeaderText="ID" /> <asp:HyperLinkField HeaderText="Click Here" _blank" DataNavigateUrlFields="clientID" DataNavigateUrlFormatString="../ClientComments.aspx?ID={0}" DataTextField="clientID" DataTextFormatString="<img src='../Images/ClientComment.gif' alt='Comment' border='0'/>" Visible="true"/> </Columns> </asp:GridView>

View Complete Post

More Related Resource Links

Send values to parent window on gridview click event


Hello all,

I have a form, which contains 2 textboxes. When i click on the first textbox, i have to open a child window (tool), that contains a gridview control with 2 columns (corresponding to the 2 textboxes). When the user clicks on any row in the gridview, it should send back the 2 column values back to the parent window to the corresponding 2 textboxes. Can anyone help me on how do i achieve this?

I can open the child window and get back the values using window.opener method in JS. 

But can anyone help on how to bind the JS code to the onClick of every row in the gridview. How can i activate the OnClick event of every row/alternating row item of the gridview and bind the JS code and pass each column value to that JS method? The no of columns in the gridview can vary depending upon the data? So in that case, i have to have a collection to be passed to JS code that can contain n number of column values.

Please help.

How to call a button click event on from an event handler



I got an event handler like this, in this event, i wanted to call another button click event. How can I do that?

protected void gwDetail_SaveCommand(object sender, System.EventArgs e)
            lblMsg.Text = "Saving...";


if (ds.Tables[0].Rows.Count == 0)

Gridview Link Button control click event


Respected Reader,

I have  Web page that uses LinkButton control inside Template Fields of Gridview.

I am trying to work on LinkButton Click event and trying to preserve the Value of LinkButton that user click, and based on that value, i want to refresh tha page data.

I used CommandName and CommandArgument property of Linkbutton, but i can use that property only in GridView_RowCommand method by checking e.CommandName expression. But the problem with that Gridview_RowCommand event fire after all other page_load activity. So the value never used in the page_load event to refresh the data in all other control.

I also tried to use OnClick Method, Session variable and Hidden variable. but when i run Response.Redirect method from Gridview_RowCommand, it clear all the Session and Hidden variable values. also tried (Response.Redirect(,false)) method but never got success.

Any suggestion will be appricated in advance.

Add a click event handler to a Chart object


Is it possible to add a click event handler to one object in an EXCEL chart?

I would like to run some code, when a user clicks on specific sector of a doughnut chart.


dougnutSectorOne_Click (object sender, eventargs e)

// runs if sector one is clicked


dougnutSectorTwo_Click (....)



is that possible in WPF?




?ButtonBase Click Event ?RoutedEvent?Handler

I am developing a usercontrol that will interact with some 3d models. The ButtonBase class has a routed event ClickEvent, which is raised eveytime a button is clicked. I am looking for the name of the event that is raised while the button remains clicked or is there another control to handle continuous input?

Button click event handler firing twice

I noticed today that button click event handlers are firing twice for me in some cases when the button is inside an UpdatePanel -- but only in Firefox.  I'm wondering if this might have to do with the Firefox update that came out today because I never noticed this problem until today.  Has anyone else run into this problem?

Dynamic event handler in VB not responding to click event


 Hi Everyone-

This event handler is not responding at all to the click event.  On click, the pagination numbers disappear and I'm not able to trace it in the debugger because the event handle doesn't even fire so I have no idea what's going on.

 Can someone please tell me why? Thanks in advance for your help!


'Create paging control
        For i As Integer = 0 To ((RowCount / 3) - 1)
            Dim lnk As New LinkButton()
            lnk.ID = "lnkPage" & (i + 1).ToString()
            AddHandler lnk.Click, AddressOf lbl_Click
            lnk.Text = (i + 1).ToString()
            Dim spacer As New Label()
            spacer.Text = " "
        Next i

Private Sub lbl_Click(ByVal sender As Object, ByVal e As EventArgs)
        'for pagination on repeater
        Dim lnk As LinkButton = TryCast(sender, LinkButton)
        Dim currentPage As Integer = Integer.Parse(lnk.Text)
        Dim take As Integer = currentPage * 3
        Dim skip As Integer = If(currentPage = 1, 0, take - 3)
        FetchData(take, skip)
    End Sub


MenuItem Click event handler not getting called from a HierarchicalDataTemplate EventSetter Style


I have a user control that contains another user control based on a button. When the button is clicked I have it show a context menu that is bound to a enumeration that shows a dynamic set of menu items. I use a HierarchicalDataTemplate to generate the MenuItems and use a style with an eventsetter to define a menu click handler to be called when any of the menu items are clicked. The context menu and its menu items gets displayed properly but the event handler is not getting called. Any ideas? Below is the section of the xaml where the user control is defined and below it is the code behind with the event handler.



<Controls:WebcastButton x:Uid="videoConfigureButton" x:Name="videoConfigureButton" 

Can't sort dataset and can't pass dataset to a textbox's click event handler. Please give me some


I have written VB code that fills a dataset from an external database. The dataset, or I suppose more correctly the datatable within the dataset, is bound to a PathListBox.ItemsSource property which is displaying fields from 5 records.

Now I need to sort the data within the dataset when the TextChanged event is fired on a text box used for "searching". The problems that I am having are that a dataset cannot be sorted (I think I have found a solution for this) and I cannot pass a dataset to the TextChanged event handler.

Obviously I am not experienced with this and I have been pouring through several books to no avail. This seems like something that should be relatively simple and I am probably over complicating it.

Would someone please offer me some suggestions (and no rtfm please... I've been doing that so much that my eyes feel like they are scraping across my keyboard).

GridView Javascript Click Row and Ajax

This article shows 2 common tasks with the ASP.NET GridView: Binding a List (generic) of objects as DataSource and on clicking a row, getting the values of the selected row by a javascript function. In the example a List with User-objects is displayed. On clicking a row containing the data of a User-object, the Id of the object is used to get the address of the user by an Ajax-call and display it in a details-field.

Reporting services in 2008 r2 how to get a report in a print button click event in my c#.net page


how to  get a report in my c#.net page button lick event also steps to call a report from asp.net to reporting services


Thanks in advance

Creating Event Handler in Code behind


Hi, so I have a control that is created in the code behind and generates fine but I can't figure out how to create an event handler for it.  I've found plenty of examples for it in C sharp, but none of them seem to apply to VB.  What I want to do is essentially this:

myDropDownList.SelectedIndexChanged = "Event to do here"

but it doesn't seem to work for me.

Any suggestions are appreciated.

determine the best way to refresh a gridview when textchanged event occurs


Good afternoon.

I have the following gridview inside an updatepanel that makes the bind from a datatable:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <asp:Button ID="ButtonAdd" runat="server" OnClick="ButtonAdd_Click" Text="Novo Artigo" />
                <asp:GridView ID="Dados" runat="server" AutoGenerateColumns="False" 
                    CssClass="Grid" Width="100%" CellPadding="4" ForeColor="#333333" 
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <asp:Button ID="AbrirModal" runat="server" Text="->" /> 
                                <asp:PopupControlExtender ID="PopupControlExtender1" runat="server"

want to launch modal Popup from created User Event handler




I have a create user wizard on my page and in the event handler (Created User) I get extra information from the user

via textboxes within the aspx etc.


I then do a response.redirect to another page.

What I want to happen is this


When the CreatedUser Event is fired, I  want a Modal Popup to show up with a message Processing your registration.

once the registration code is processed it will close and the users get redirected.


On my ASPX I have the Modal PopUp and a Panel.

In the code behind in the handler I put ModalPop.show()


but this does not work.


thanks for any suggestions



Custom Grid View Header - Grid view Row Created event vs Gridview row databound events ?


Hi Gurus ,

It happened to add an extra Gridveiw Header in row_databound event , It did worked fine on !Postback but disappered on Page.Postback . Quick google search guided me to move the event to Row_Created event and every thing is okay .

Can any expert post some pointers , differnces between grid row_created vs row_databount with some sample table data created dynamically  behaviour of both the events in !Postback and page.Postback .

Thanks a tonne in Advance and  any inputs will be valued and appreciated .

gridview tablecell text emptystring in RowDataBound event when editing


HI and thanks in advance.  asp.net using vb, using a codebehind page.

I have a relatively simple gridview bound to an product table that displays great.  The problem comes when I choose to edit a row.  When I do so, the gridviews' RowDataBound event fires and the values of the text properties of the tablecells in the row evaluate to "" emptystring. 

I do notice that if I break within the GridView1_RowDataBound event during a refresh of the page, the values are there.  But again, when I hit the "Edit" button in the first column (the CommandField column) .  Text properties of the cells resolve to ""

 Here is the code for the event, followed by the gridview in the form (inside an updatepanel)

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then  ' not a header, footer row.. etc.
            Dim cellProductNumber As TableCell = e.Row.Cells(3) ' ProductNumber column

'>>>>> after clicking "update", even though a value displays in the gridview,
' the cellProductNumber.Te

InfoPath Workflow Task Form "Loading" event handler only being called after App Pool recycled.


I have a Workflow that is using an InfoPath task form.  In the "FormEvents_Loading" method event handler I have some code that needs to run each time the form is opened.   I recycle the App Pool and open the form the code runs perfectly, but if I close and try to re-open the form the code is not run at all.  I can then recycle the App Pool again and on the next load the code executes just fine.   The code that is supposed to be run is a very simple statement to set a field value, so I don't think it is interfering.

Does anyone know what this might be?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend