repeater嵌套 10
怎样让子级只显示在父级下面aspx代码<div><asp:RepeaterID="RepeaterShow"runat="server"OnItemCommand="Re...
怎样让子级只显示在父级下面
aspx代码
<div>
<asp:Repeater ID="RepeaterShow" runat="server"
OnItemCommand="RepeaterShow_ItemCommand"
onitemdatabound="RepeaterShow_ItemDataBound">
<ItemTemplate>
<asp:LinkButton ID="LinkButtonShow" runat="server" CssClass="" CommandName="LinkButtonGoto"
CommandArgument='<%#Eval ("PermissionsTypeGUID") %>'> <%#((DataRowView)Container.DataItem)["PermissionsTypeName"]%></asp:LinkButton><br />
<div>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%#((DataRowView)Container.DataItem)["PermissionsName"]%><br />
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
cs代码
protected void RepeaterShow_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep = e.Item.FindControl("Repeater1") as Repeater;//找到里层的repeater对象
ServiceReference1.ServiceClearClient clientuserinfo = new ServiceReference1.ServiceClearClient();
ServiceReference1.SMenuInfo[] smenuInfo = clientuserinfo.GetSMenu(strGuie, strPermissionsAbridges);
if (strGuie != "-1")
{
if (smenuInfo.Length > 0)
{
DataTable dt = new DataTable();
dt.Columns.Add("PermissionsName");
for (int i = 0; i < smenuInfo.Length; i++)
{
DataRow dr = dt.NewRow();
dr["PermissionsName"] = smenuInfo[i].PermissionsName;
dt.Rows.Add(dr);
}
rep.DataSource = dt;
rep.DataBind();
}
}
}
} 展开
aspx代码
<div>
<asp:Repeater ID="RepeaterShow" runat="server"
OnItemCommand="RepeaterShow_ItemCommand"
onitemdatabound="RepeaterShow_ItemDataBound">
<ItemTemplate>
<asp:LinkButton ID="LinkButtonShow" runat="server" CssClass="" CommandName="LinkButtonGoto"
CommandArgument='<%#Eval ("PermissionsTypeGUID") %>'> <%#((DataRowView)Container.DataItem)["PermissionsTypeName"]%></asp:LinkButton><br />
<div>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%#((DataRowView)Container.DataItem)["PermissionsName"]%><br />
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
cs代码
protected void RepeaterShow_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep = e.Item.FindControl("Repeater1") as Repeater;//找到里层的repeater对象
ServiceReference1.ServiceClearClient clientuserinfo = new ServiceReference1.ServiceClearClient();
ServiceReference1.SMenuInfo[] smenuInfo = clientuserinfo.GetSMenu(strGuie, strPermissionsAbridges);
if (strGuie != "-1")
{
if (smenuInfo.Length > 0)
{
DataTable dt = new DataTable();
dt.Columns.Add("PermissionsName");
for (int i = 0; i < smenuInfo.Length; i++)
{
DataRow dr = dt.NewRow();
dr["PermissionsName"] = smenuInfo[i].PermissionsName;
dt.Rows.Add(dr);
}
rep.DataSource = dt;
rep.DataBind();
}
}
}
} 展开
3个回答
展开全部
干嘛非要用repeater?难道手动拼字符串在前台显示不能满足你?
更多追问追答
追问
你说的手动拼字符串是什么意思
追答
比如
改为
.aspx:
aspx.cs:
public showStr="";
//在后台将前台显示的html拼接出来
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我先研究研究
追问
研究出来的告诉我,我等着
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询