tkaragiris posted on September 03, 2010 10:31

To trigger a function or sub from a linkbutton in a gridview footer follow these steps:
- Put a gridview on your page with some datarows in it
- Edit the templates on the gridview and insert a linkbutton in the footer template of the column where you want the linkbutton to go.
- Edit the tag of the linkbutton and put the name of a function or sub in the "Onclick" property of the linkbutton's tag.
- Then create a function or sub in your code with the same name.
- This function or sub will then fire when the linkbutton is clicked.
See example below:
In the aspx page, here is the code in the gridview's column footer template:
<FooterTemplate>
<asp:LinkButton ID="lnkRelease" runat="server" CommandName="Select" OnClick="Release"
onclientclick="javascript:return confirm("Are you sure?");">Update selected</asp:LinkButton>
</FooterTemplate>
Here is the code in vb code page:
Sub Release()
For Each grRow As GridViewRow In gvCourseRelease.Rows
If grRow.RowType = DataControlRowType.DataRow Then
If CType(grRow.FindControl("chkSelect"), CheckBox).Checked Then
' Do something with the checked row....
End If
End If
Next
End Sub