TKC Blog
03

To trigger a function or sub from a linkbutton in a gridview footer follow these steps:

  1. Put a gridview on your page with some datarows in it
  2. Edit the templates on the gridview and insert a linkbutton in the footer template of the column where you want the linkbutton to go.
  3. Edit the tag of the linkbutton and put the name of a function or sub in the "Onclick" property of the linkbutton's tag.
  4. Then create a function or sub in your code with the same name.
  5. 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(&quot;Are you sure?&quot;);">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

 

Search Blog