0

我有个问题。这是我的 html 代码。

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                    <ContentTemplate>
                        <asp:ScriptManager ID="ScriptManager1" runat="server">
                        </asp:ScriptManager>
                        <asp:ListView ID="ListView1" runat="server">
                        <LayoutTemplate>
                            <table border="0" cellpadding="1">
                                <tr style="background-color:#E5E5FE">
                                    <th align="left"><asp:LinkButton ID="lnkId" runat="server" CommandName="Sort" CommandArgument="ID">Id</asp:LinkButton></th>
                                    <th align="left"><asp:LinkButton ID="lnkName" runat="server" CommandName="Sort" CommandArgument="TelcoName">TelcoName</asp:LinkButton></th>
                                    <th align="left"><asp:LinkButton ID="lnkReloadValue" runat="server" CommandName="Sort" CommandArgument="Reload Value">Reload Value(RM)</asp:LinkButton></th>
                                    <th align="left"><asp:LinkButton ID="lnkQuantity" runat="server" CommandName="Sort" CommandArgument="Quantity">Quantity</asp:LinkButton></th>                                    
                                    <th></th>
                                </tr>
                               <tr id="itemPlaceholder" runat="server"></tr>
                            </table>
                        </LayoutTemplate>
                        <ItemTemplate>
                        <tr>
                        <td><asp:Label runat="server" ID="lblId"><%#Eval("ID") %></asp:Label></td>
                        <td><asp:Label runat="server" ID="lblTelcoName"><%#Eval("TelcoName") %></asp:Label></td>
                        <td><asp:Label runat="server" ID="lblReloadValue"><%#Eval("Reload Value (RM)")%></asp:Label></td>
                        <td><asp:Label runat="server" ID="lblQuantity"><%#Eval("Quantity")%></asp:Label></td>
                        </tr>
                        </ItemTemplate>
                        </asp:ListView>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </ContentTemplate>
        </asp:UpdatePanel>

这就是代码的背后

Dim dt As New DataTable
        Dim i = 0
        Dim ID As New DataColumn("ID")
        dt.Columns.Add(ID)
        Dim TelcoName As New DataColumn("TelcoName")
        dt.Columns.Add(TelcoName)
        Dim ReloadValue As New DataColumn("Reload Value (RM)")
        dt.Columns.Add(ReloadValue)
        Dim Quantity As New DataColumn("Quantity")
        dt.Columns.Add(Quantity)
        ListView1.DataSource = dt
        ListView1.DataBind()

        ID.AutoIncrement = True
        ID.AutoIncrementSeed = 1
        ID.ReadOnly = True

        Dim data() As String

        data = Session("Transaction")

        If data(0) <> "" Then
            Dim Maxis() As String
            Maxis = data(0).Split(";")
            Dim dr1 As DataRow = dt.NewRow()
            dr1("TelcoName") = Maxis(0)
            dr1("Reload Value (RM)") = Maxis(1)
            dr1("Quantity") = Maxis(2)
            dt.Rows.Add(dr1)
            ListView1.DataSource = dt
            ListView1.DataBind()
        End If

        If data(1) <> "" Then
            Dim XPax() As String
            XPax = data(1).Split(";")
            Dim dr2 As DataRow = dt.NewRow()
            dr2(1) = XPax(0)
            dr2(2) = XPax(1)
            dr2(3) = XPax(2)
            dt.Rows.Add(dr2)
            ListView1.DataSource = dt
            ListView1.DataBind()
        End If

不知何故,我收到一个错误“数据绑定:”System.Data.DataRowView“不包含名为“重新加载值”的属性。当我调试时,该列应该已填满,但我不知道这里有什么问题。任何人都可以帮助我吗?

4

1 回答 1

0

不要在列名中使用任何空格和 ()

尝试更改此行

 Dim ReloadValue As New DataColumn("ReloadValueRM")

        dr1("ReloadValueRM")

    <%#Eval("ReloadValueRM")%>

编辑

并更改为

CommandArgument="**ReloadValueRM**">
于 2013-03-07T07:22:20.050 回答