开发者

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 S开发者_高级运维tring() = 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.


<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


Put the name of the key field of the database in a public variable, so you do not syntax error

public string registerKey = "myId";

protected void btnCancel_Command (object sender, CommandEventArgs e)
{
    // With the CommandEventArgs you get the parameters sent
    UpdatePanel2.Update ();
}

<asp: Button ID = "btnCancel" Text = "Cancel" CommandName = "CancelDeposit" OnCommand = "btnCancel_Command" runat = "server" CommandArgument = '<% # DataBinder.GetPropertyValue (Container.DataItem, registerKey)%> ">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜