0

这似乎应该是一个简单的答案,但我到处搜索,似乎找不到我想要做的事情,我对此很陌生,所以我可能会遗漏一些东西......希望有人能提供帮助.

这样做的目的是显示我要送修的扫描仪(dl)的装箱单,并且每个维修问题都有注释(gv)。我能够让 dl 正确显示,但我根本无法让 gv 显示。即使我对“问题密钥”进行硬编码。我得到一个 Object not set to object 错误。显然我不能保持硬编码,所以我尝试从 dl 中提取问题密钥(通过 DataKey)并将其传递给 gv,我得到“索引超出范围”。(当我通过它出现-1)。

这是我正在使用的代码....谢谢

Sub LoadShippingList()
    dlShippingList.DataSource = WarehouseManager.GetScannerIssuesByScannerStatus(WarehouseManager.ScannerStatus.PendingShipForRepair)
    dlShippingList.DataBind()
End Sub

Protected Sub dlShippingList_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlShippingList.ItemDataBound
    Dim dList As DataList = CType(sender, DataList)
    Dim intScannerIssueKey As Integer = dList.DataKeys(e.Item.ItemIndex)

    Dim gv As GridView
    gv = CType(e.Item.FindControl("gvShippingListIssueNotes"), GridView)
    gv.DataSource() = WarehouseManager.GetScannerIssueNotes(intScannerIssueKey)
    gv.DataBind()

End Sub


<asp:Panel ID="pnlShippingList" runat="server">
            <asp:Label ID="lblShippingListCaption" runat="server" Text="Shipping List" SkinID="PageTitle"></asp:Label>
            <br />
            <asp:DataList ID="dlShippingList" runat="server" GridLines="Both" DataKeys="ScannerIssueKey" DataKeyField="ScannerIssueKey">
                <HeaderTemplate>
                    <table>
                        <tr>
                            <td>
                                <asp:Label ID="lblShipmentNumberCaption" runat="server" Text="Shipment:" SkinID="FieldLabel"></asp:Label>
                            </td>
                            <td>
                                <asp:Label ID="lblShipmentNumber" runat="server" SkinID="FeedbackMessageSmallDark"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="lblShipmentDateCaption" runat="server" Text="Date:" SkinID="FieldLabel"></asp:Label>
                            </td>
                            <td>
                                <asp:Label ID="ShipmentDate" runat="server" SkinID="FeedbackMessageSmallDark"></asp:Label>
                            </td>
                        </tr>
                    </table>
                </HeaderTemplate>
                <ItemTemplate>
                    Issue #:<asp:Label ID="lblScannerIssueKey" runat="server" Text='<%# Eval("ScannerIssueKey") %>'></asp:Label>
                    Scanner #:
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("ScannerKey") %>'></asp:Label>
                    Subject:<asp:Label ID="Label2" runat="server" Text='<%# Eval("IssueDescription") %>'></asp:Label>
                    <br />
                    Notes:<br />
                    <asp:GridView ID="gvShippingListIssueNotes" HorizontalAlign="Left" runat="server"
                        Font-Size="Medium" EmptyDataText="No Notes" AutoGenerateColumns="false" SkinID="SimpleGrid">
                        <RowStyle VerticalAlign="Top" HorizontalAlign="Center" />
                        <Columns>
                            <asp:BoundField HeaderText="Notes" DataField="Notes" />
                            <asp:BoundField HeaderText="User" DataField="UserEntered" />
                            <asp:BoundField HeaderText="Date" DataField="DateAndTime" />
                        </Columns>
                    </asp:GridView>
                    <br />
                </ItemTemplate>
                <FooterTemplate>
                    Weissmans's 6750 Manchester Avenue St. Louis MO 63139</FooterTemplate>
            </asp:DataList>
            <br />
        </asp:Panel>
4

1 回答 1

0

我想我找到了自己的答案....在 DataList 的 ASP 中,我在 vb 上添加了 onItemDataBound="dlShippingList_ItemDataBound" 我取出... 处理 dlShippingList.ItemDataBound SOFAR,它似乎工作得很好!

于 2013-01-17T20:44:22.847 回答