gpt4 book ai didi

asp.net - ASP : CommandArgument

转载 作者:行者123 更新时间:2023-12-02 10:01:13 26 4
gpt4 key购买 nike

我正在尝试在将值绑定(bind)到按钮的转发器内传递值,并将它们从该表单传递到另一个表单。当我编译它时,它给我一个错误,指示

System.FormatException:输入字符串的格式不正确。

form1.aspx 中中继器代码中的按钮:

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

在form1.aspx.vb中Repeater_ItemCommand功能:

 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

这个问题有什么解决办法吗?问候。

最佳答案

<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

关于asp.net - ASP : CommandArgument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5857763/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com