能在repeater的HeaderTemplate绑定数据吗
1个回答
展开全部
<asp:Repeater ID="repeater1" runat="server"
onitemdatabound="repeater1_ItemDataBound">
<HeaderTemplate>
<table width="75%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td height="30" bgcolor="#e6edf2" align="center">角色 | 操作</td>
<asp:Repeater ID="repeater2" runat="server">
<ItemTemplate>
<td height="30" align="center" bgcolor="#e6edf2"><span class="S1"><strong><%# Eval("powerName") %></strong></span></td>
</ItemTemplate>
</asp:Repeater>
<td height="30" align="center" bgcolor="#e6edf2"><span class="S1"><strong>操作</strong></span></td>
</tr>
</HeaderTemplate>
我用的是2个listview(你的是repeater 其实都一样的,自己看这改吧)
先循环出标题的,在根据标题的id循环出每一个标题包含的
cs代码:
DataTable dt_category = Maticsoft.DBUtility.DbHelperSQL.Query("select * from category").Tables[0];
this.lv_category.DataSource = dt_category;
this.lv_category.DataBind();
for (int i = 0; i < dt_category.Rows.Count; i++)
{
ListView lv_size = this.lv_category.Items[i].FindControl("lv_size") as ListView;
DataTable dt_size = Maticsoft.DBUtility.DbHelperSQL.Query("select * from size where sizwe_Category_ID =" + dt_category.Rows[i]["category_id"]).Tables[0];
lv_size.DataSource = dt_size;
lv_size.DataBind();
}
aspx代码:
<asp:ListView runat="server" ID="ListView1">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<dt><a href='<%# "Default2.aspx?hf_category="+Eval("Category_ID") %>'>
<%#Eval("category_name") %></a></dt>
<asp:ListView runat="server" ID="lv_size">
<LayoutTemplate>
<dd>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</dd>
</LayoutTemplate>
<ItemTemplate>
<a href='<%# "Default2.aspx?hf_size="+Eval("size_ID")+ "&hf_category="+Eval("sizwe_Category_ID")%>'>
<%#Eval("sizer_measures") %></a>
</ItemTemplate>
</asp:ListView>
</ItemTemplate>
</asp:ListView>
onitemdatabound="repeater1_ItemDataBound">
<HeaderTemplate>
<table width="75%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td height="30" bgcolor="#e6edf2" align="center">角色 | 操作</td>
<asp:Repeater ID="repeater2" runat="server">
<ItemTemplate>
<td height="30" align="center" bgcolor="#e6edf2"><span class="S1"><strong><%# Eval("powerName") %></strong></span></td>
</ItemTemplate>
</asp:Repeater>
<td height="30" align="center" bgcolor="#e6edf2"><span class="S1"><strong>操作</strong></span></td>
</tr>
</HeaderTemplate>
我用的是2个listview(你的是repeater 其实都一样的,自己看这改吧)
先循环出标题的,在根据标题的id循环出每一个标题包含的
cs代码:
DataTable dt_category = Maticsoft.DBUtility.DbHelperSQL.Query("select * from category").Tables[0];
this.lv_category.DataSource = dt_category;
this.lv_category.DataBind();
for (int i = 0; i < dt_category.Rows.Count; i++)
{
ListView lv_size = this.lv_category.Items[i].FindControl("lv_size") as ListView;
DataTable dt_size = Maticsoft.DBUtility.DbHelperSQL.Query("select * from size where sizwe_Category_ID =" + dt_category.Rows[i]["category_id"]).Tables[0];
lv_size.DataSource = dt_size;
lv_size.DataBind();
}
aspx代码:
<asp:ListView runat="server" ID="ListView1">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<dt><a href='<%# "Default2.aspx?hf_category="+Eval("Category_ID") %>'>
<%#Eval("category_name") %></a></dt>
<asp:ListView runat="server" ID="lv_size">
<LayoutTemplate>
<dd>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</dd>
</LayoutTemplate>
<ItemTemplate>
<a href='<%# "Default2.aspx?hf_size="+Eval("size_ID")+ "&hf_category="+Eval("sizwe_Category_ID")%>'>
<%#Eval("sizer_measures") %></a>
</ItemTemplate>
</asp:ListView>
</ItemTemplate>
</asp:ListView>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
Storm代理
2023-07-25 广告
2023-07-25 广告
StormProxies是一家可靠的代理服务提供商,提供原生IP(住宅原生IP)和高匿名代理服务。以下是关于StormProxies的原生IP服务的一些信息:1. 住宅原生IP:StormProxies提供的住宅原生IP是指从真实的家庭或企...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询