私は以下のようなASPネストされたリピータを持っている:ASPネストされたリピータエラー
<asp:Repeater ID="rptMenu" runat="server">
<ItemTemplate>
<div class="box">
<div class="box-header">
<h3 class="box-title"><asp:Label ID="lblHeader" runat="server"></asp:Label></h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped">
<tr>
<th style="width: 10px">#</th>
<th>ID</th>
<th>Nama</th>
</tr>
<tr>
<asp:Repeater ID="rptDetail" runat="server">
<ItemTemplate>
<td><asp:CheckBoxList ID="cblChild" runat="server"></asp:CheckBoxList></td>
<td><asp:Label ID="LblID" runat="server"></asp:Label></td>
<td><asp:Label ID="LblName" runat="server"></asp:Label></td>
</ItemTemplate>
</asp:Repeater>
</tr>
</table>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
そしてここで何の背後にあるコード: ページがロードされると、それはLoad_menu()
呼んでいる:結合
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
If Not Page.IsPostBack Then
Call Load_menu()
End If
Catch ex As Exception
Response.Write("Page_Load Exception :<br>" & ex.ToString)
End Try
End Sub
ここLoad_menu()
機能をリピーターに:
Private Sub Load_menu()
Try
sqlstring = "SELECT DISTINCT a.parent, b.name FROM masterMenu a join masterMenu b " & _
"ON a.parent = b.menuID JOIN rolesDetail c " & _
"ON a.menuID = c.menuID " & _
"WHERE b.[status] = 1 "
DS = SQLExecuteQuery(sqlstring)
DT = DS.Tables(0)
rptMenu.DataSource = DT
rptMenu.DataBind()
Catch ex As Exception
Response.Write("Load_Menu Exception :<br>" & ex.ToString)
End Try
End Sub
ND最初のリピータrptMenu
:私はすべてのクエリが有効で動作していることを確認している
Private Sub rptDetail_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptMenu.ItemDataBound
Try
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim lblID As Label = e.Item.FindControl("LblID")
Dim lblName As Label = e.Item.FindControl("LblName")
Dim cblChild As CheckBoxList = e.Item.FindControl("cblChild")
Dim dr As DataRowView = e.Item.DataItem
lblID.Text = dr.Item("menuID").ToString
lblName.Text = dr.Item("name").ToString
End If
Catch ex As Exception
Throw New Exception("<b>Error RptDetail Data bound :</b>" & ex.ToString)
End Try
End Sub
:
Private Sub rptMenu_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptMenu.ItemDataBound
Try
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim rDS As New DataSet
Dim rDT As New DataTable
Dim lblHeader As Label = e.Item.FindControl("lblHeader")
Dim dr As DataRowView = e.Item.DataItem
lblHeader.Text = dr.Item("name").ToString
sqlstring = "SELECT a.menuID, a.name, b.[status] " & _
"FROM masterMenu a LEFT JOIN rolesDetail b ON b.menuID=a.menuID " & _
"WHERE a.[status] = 1 and a.parent= '" & dr.Item("parent") & "' and b.RoleID = '" & roleID & "' " & _
"ORDER BY a.menuID "
rDS = SQLExecuteQuery(sqlstring)
rDT = rDS.Tables(0)
rptDetail.DataSource = rDT
rptDetail.DataBind()
End If
Catch ex As Exception
Throw New Exception("<b>Error RptMenu Data bound :</b>" & ex.ToString)
End Try
End Sub
ここは第二の中継rptDetail
をバインドします。次のエラーが表示されます。
Load_Menu Exception :
System.Exception: Error RptDetail Data bound :System.ArgumentException: menuID is neither a DataColumn nor a DataRelation for table Table.
at System.Data.DataRowView.get_Item(String property)
at LMS.role_detail.rptDetail_ItemDataBound(Object sender, RepeaterItemEventArgs e) in D:\Others\Ekspedisi\LMS\konfigurasi\role-detail.aspx.vb:line 165
at LMS.role_detail.rptDetail_ItemDataBound(Object sender, RepeaterItemEventArgs e) in D:\Others\Ekspedisi\LMS\konfigurasi\role-detail.aspx.vb:line 178
at System.Web.UI.WebControls.RepeaterItemEventHandler.Invoke(Object sender, RepeaterItemEventArgs e)
at System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem)
at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e)
at LMS.role_detail.Load_menu() in D:\Others\Ekspedisi\LMS\konfigurasi\role-detail.aspx.vb:line 120
このエラーは発生しておらず、結果もありません。私は意味が理解できないneither datacolumn
。私はテーブルをチェックして、menuID
がその列に存在するはずです。どんな助けもありがとう。ありがとうございました。
追加されました: 私は、Visual Studio 2012とSQL Serverを使用しています2014ここで
masterMenu
表と例:
CREATE TABLE [dbo].[masterMenu](
[menuID] [varchar](255) NOT NULL,
[name] [varchar](255) NULL,
[order] [int] NULL,
[level] [int] NULL,
[parent] [varchar](255) NOT NULL,
[icon] [varchar](255) NULL,
[cssClass] [varchar](255) NULL,
[url] [varchar](255) NULL,
[target] [varchar](255) NOT NULL,
[lastModified] [datetime] NULL CONSTRAINT [DF__MasterMen__lastm__15502E78] DEFAULT (NULL),
[status] [smallint] NULL CONSTRAINT [DF__MasterMen__statu__164452B1] DEFAULT ((1)),
[timestamp] [datetime] NULL CONSTRAINT [DF__MasterMen__times__173876EA] DEFAULT (getdate()),
CONSTRAINT [PK__MasterMe__3214EC271367E606] PRIMARY KEY CLUSTERED
(
[menuID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[masterMenu] ([menuID], [name], [order], [level], [parent], [icon], [cssClass], [url], [target], [lastModified], [status], [timestamp]) VALUES (N'A0000', N'Kategori Berat', 100000000, 1, N'A0000', N'fa fa-balance-scale', NULL, N'/master/category.aspx', N'content', NULL, 1, CAST(N'2010-03-05 11:51:47.293' AS DateTime))
INSERT [dbo].[masterMenu] ([menuID], [name], [order], [level], [parent], [icon], [cssClass], [url], [target], [lastModified], [status], [timestamp]) VALUES (N'B0000', N'Transaksi Kontainer', 200000000, 1, N'B0000', N'fa fa-truck', N'', N'/warehouse/transaksi.aspx', N'content', NULL, 1, CAST(N'2010-01-25 15:02:58.000' AS DateTime))
INSERT [dbo].[masterMenu] ([menuID], [name], [order], [level], [parent], [icon], [cssClass], [url], [target], [lastModified], [status], [timestamp]) VALUES (N'C0000', N'Report', 300000000, 1, N'C0000', N'fa fa-file-text', N'fa fa-chevron-down', N'#', N'content', NULL, 1, CAST(N'2010-03-08 11:41:12.457' AS DateTime))
INSERT [dbo].[masterMenu] ([menuID], [name], [order], [level], [parent], [icon], [cssClass], [url], [target], [lastModified], [status], [timestamp]) VALUES (N'C0001', N'Daftar Transaksi Kontainer', 301000000, 2, N'C0000', N'fa fa-circle', N'', N'/reports/listContainerTransaction.aspx', N'content', NULL, 1, CAST(N'2010-03-08 11:41:12.457' AS DateTime))
INSERT [dbo].[masterMenu] ([menuID], [name], [order], [level], [parent], [icon], [cssClass], [url], [target], [lastModified], [status], [timestamp]) VALUES (N'C0002', N'Rencana Muat Kapal', 301000000, 2, N'C0000', N'fa fa-circle', N'', N'/reports/loadingPlan.aspx', N'content', NULL, 1, CAST(N'2010-03-08 11:41:12.457' AS DateTime))
INSERT [dbo].[masterMenu] ([menuID], [name], [order], [level], [parent], [icon], [cssClass], [url], [target], [lastModified], [status], [timestamp]) VALUES (N'E0000', N'Konfigurasi', 500000000, 1, N'E0000', N'fa fa-gears', N'fa fa-chevron-down', N'#', N'content', NULL, 1, CAST(N'2010-01-25 15:02:58.000' AS DateTime))
INSERT [dbo].[masterMenu] ([menuID], [name], [order], [level], [parent], [icon], [cssClass], [url], [target], [lastModified], [status], [timestamp]) VALUES (N'E0001', N'Master Company', 501000000, 2, N'E0000', N'fa fa-building', NULL, N'/master/company.aspx', N'content', NULL, 1, CAST(N'2010-03-05 11:51:47.293' AS DateTime))
INSERT [dbo].[masterMenu] ([menuID], [name], [order], [level], [parent], [icon], [cssClass], [url], [target], [lastModified], [status], [timestamp]) VALUES (N'E0003', N'Pendaftaran User', 503000000, 2, N'E0000', N'fa fa-user', NULL, N'/konfigurasi/user.aspx', N'content', NULL, 1, CAST(N'2010-01-25 15:02:58.000' AS DateTime))
INSERT [dbo].[masterMenu] ([menuID], [name], [order], [level], [parent], [icon], [cssClass], [url], [target], [lastModified], [status], [timestamp]) VALUES (N'E0004', N'Roles', 504000000, 2, N'E0000', N'fa fa-unlock', NULL, N'/konfigurasi/roles.aspx', N'content', NULL, 1, CAST(N'2010-01-25 15:02:58.000' AS DateTime))
rptMenuを指しているように見えるので、最初のクエリでもmenuIDを選択してください(Load_menu())。私はあなたの問題を解決するだろうと思う – Aby