HShbib HShbib - 23 days ago 7
Vb.net Question

ASP: CommandArgument

I am trying to pass values within a repeater binding them to a button and pass them from this form to another form. When i compile this it gives me an error indicating

System.FormatException: Input string was not in a correct format.


Button within Repeater Code in form1.aspx:

<asp:Button ID="Button1" runat="server" Text="" CommandName= "TEST" CommandArgument = '<%# Eval("Parking_ID") + "," + Eval("Parking_Name") %>' />


in form1.aspx.vb Repeater_ItemCommand Function:

Protected Sub repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles repeater1.ItemCommand
If (e.CommandName = "TEST") Then
Dim commandArgsAccept As String() = e.CommandArgument.ToString().Split(New Char() {","c})
Dim value As Int32 = commandArgsAccept(0).ToString
Dim value1 As String = commandArgsAccept(1).ToString

Response.Redirect("Default2.aspx?Parking_ID=" & value, True)
Response.Redirect("Default2.aspx?Parking_Name=" & value1, True)


Session("field4") = value
Session("field6") = value1


End If






End Sub


Any solution for this problem?
Regards.

Answer
<asp:Button ID="Button1" runat="server" Text="" CommandName= "TEST"  CommandArgument = '<%# Eval("Parking_ID").ToString() +","+ Eval("Parking_Name").ToString() %>'/>


 Protected Sub repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles repeater1.ItemCommand
        If (e.CommandName = "TEST") Then
            Dim commandArgsAccept As String() = e.CommandArgument.ToString().Split(",")
            Dim value As Int32 = commandArgsAccept(0).ToString
            Dim value1 As String = commandArgsAccept(1).ToString




            Session("field4") = value
            Session("field6") = value1

            Response.Redirect("Default2.aspx?Parking_ID=" & value & "&Parking_Name=" & value1, True)


        End If