2

请帮忙,我被卡住了。我有一个获取和填充网格的存储过程。我尝试在 Command 参数中传递一个数值,并根据我的标题得到未处理的异常。我试过查看 DBML,但什么也没看到。这是我的代码:

</asp:TemplateField>
        <asp:BoundField DataField="name"  HeaderText="Player" />
        <asp:BoundField DataField="dsc" HeaderText="Desc." />
        <asp:BoundField DataField="cond" HeaderText="Cond." />
        <asp:BoundField DataField="maker" HeaderText="Make" />
        <asp:BoundField DataField="year" HeaderText="Year" />
        <asp:BoundField DataField="price" HeaderText="Price" DataFormatString="{0:C}"/>      
        <asp:BoundField DataField="qty" HeaderText="Qty." />
        <asp:TemplateField HeaderText="Buy">
            <ItemTemplate>
                <asp:Button ID="Button2" runat="server" Text="Buy" ToolTip="Add to Cart" OnClientClick="GridView1_SelectedIndexChanged" CommandArgument='<% #Eval("name") + "," + Eval("price") + "," + Eval("pic") %>'></asp:Button>
            </ItemTemplate>
        </asp:TemplateField>

背后的代码:

Dim btn As Button = CType(sender, Button)
Dim commandName As String = btn.CommandName
Dim commandArg As String() = btn.CommandArgument.ToString.Split(",")
Dim argName As String = commandArg(0)
Dim argDsc As String = commandArg(1)
Dim argPrice As String = commandArg(2)
Dim argPic As String = commandArg(3)

提前致谢

4

1 回答 1

0

鉴于这Price是某种货币数字格式,您需要在连接 button 时将其转换为字符串CommandArgument

<asp:Button ... CommandArgument='<% #Eval("name") + "," 
+ Eval("price").ToString() + ","
+ Eval("pic") %>'>
于 2013-10-20T17:24:10.677 回答