这似乎应该是一个简单的答案,但我已经到处寻找这个,似乎无法找到我想做的事情,我是新手,所以我可能会遗漏一些东西......希望有人可以帮忙。
这样做的目的是显示我要发送修理的扫描仪(dl)的装箱单,每个修理问题都有注释(gv)。我能够正确显示dl,但我根本无法显示gv。即使我硬编码“问题密钥”。我得到一个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>
答案 0 :(得分:0)
我认为我发现了自己的答案....在DataList的ASP中我在vb上添加了onItemDataBound =“dlShippingList_ItemDataBound”我拿出了...处理dlShippingList.ItemDataBound SOO FAR,它似乎工作得很好! / p>