• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

ASP.NET Gridview botton / link column


I have a VB application using a gridview that is being populated from a datatable in the backend. I am not using autogeneratecolumns and have manually specified all columns. 9 of them are standard read-only columns and three of them I want to contain data but also be clickable. I want each of these three clickable columns to fire an event so I can pass the value in the column the user clicked onto another page.

For example if the user clicks on the second clickable column it fires an event that gets the data from the exact same column they clicked on. I have it so I can get the row that was clicked but in this case I need the exacy column.

Is this possible?

Thanks in advance and regards.
1 Solution
User button filed for clickable columns like below

<asp:ButtonField CommandName="test1" Text="bind datatables column" />
            <asp:ButtonField CommandName="test2" Text="bind datatables column" />
            <asp:ButtonField CommandName="test3" Text="bind datatables column" />

and in code behind create event for datagrid row comannad as below. In this event check for command name and do the process.

Protected Sub grdCuttings_RowCommand(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewCommandEventArgs ) Handles
If e.CommandName = "test1" Then
'I do my stuff here
elseif If e.CommandName = "test2" Then
'do process for test2
End If
End Sub
rite_ehAuthor Commented:
Excellent, exactly what I was after! I figured there was some property of the column I was overlooking.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now