Wednesday, 30 April 2014

Pass Multiple Parameter by CommandArgument in GridView

In Aspx Page:
 <asp:TemplateField  ItemStyle-HorizontalAlign="left" HeaderStyle-Font-Underline="false">
     <ItemTemplate>
              <asp:LinkButton ID="Emp_Name" runat="server" Text='<%#Eval("QueryNo")%>' CommandArgument='<%# Eval("QueryNo") + ";" + Eval("QueryYear")%>' OnClick="Emp_Name_Click" />
       </ItemTemplate>
</asp:TemplateField>

In VB Page:
Protected Sub Emp_Name_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim b As LinkButton = DirectCast(sender, LinkButton)

        Dim arguments As String = b.CommandArgument
        Dim args As String() = arguments.Split(";"c)

        Dim QN As String = args(0)
        Dim QY As String = args(1)

        Response.Redirect("details.aspx?Q=" & QN & "&Y=" & QY)
    End Sub


No comments:

Post a Comment