sid name text
A a 1233
B b 45454
C c 78744
A d 81211
A e 84566
说明:Repeater1,里嵌套Repeater2。Repeater1绑定表table1_Sid不重复数据,结果A B C。Repeater2按着Repeater1绑定的结果查询字段name text。要显示的结果举例,A(a,b,c)B(b)C(c)
问题?如何获得Repeater1当前绑定的Sid,以便作为查询Repeater2查询依据?
最好把代码写出来,呵呵~~多谢!~
6 个解决方案
#1
protected void rpt_parentProduct_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
DataTable dt;
Repeater rpt = e.Item.FindControl("rpt_cateProduct") as Repeater;//找到嵌套的repearer
HtmlInputHidden hdparentid = e.Item.FindControl("hd_parentid") as HtmlInputHidden;//找个repeater1行的ID号 楼主的A
int companyid = logic.customer.getCompanyId();
int parentid = 0;
int.TryParse(hdparentid.Value, out parentid);
dt = DAL.DbHelper.ExecuteDataTable("P_category_select_SellerRange_smallCate", companyid, parentid);
rpt.DataSource = dt;
rpt.DataBind();
}
}
#2
顶!
#3
http://blog.csdn.net/greatverve/archive/2008/12/26/3600912.aspx
看看Repeater的嵌套用法。
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView drv = e.Item.DataItem as DataRowView;
Repeater child = e.Item.FindControl("rptChild") as Repeater;
child.DataSource = OleDbHelper.ExecuteDt("select * from type_2 where typeid_1 =" + drv["typeid_1"].ToString());
child.DataBind();
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/greatverve/archive/2008/12/26/3600912.aspx
drv["typeid_1"].ToString());这样得到。
看看Repeater的嵌套用法。
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView drv = e.Item.DataItem as DataRowView;
Repeater child = e.Item.FindControl("rptChild") as Repeater;
child.DataSource = OleDbHelper.ExecuteDt("select * from type_2 where typeid_1 =" + drv["typeid_1"].ToString());
child.DataBind();
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/greatverve/archive/2008/12/26/3600912.aspx
drv["typeid_1"].ToString());这样得到。
#4
DataTable dtParent = //table1_Sid
dtParent.TableName = "parent";
DataTable dtChild = //table1_child 表里需要包含table1_Sid sid字段
dtChild.TableName = "child";
DataSet ds = new DataSet();
ds.Tables.Add(dtParent);
ds.Tables.Add(dtChild);
ds.Relations.Add(new DataRelation("child",dtParent.Columns["sid"],dtChild.Columns["sid这里是子表的外键"],false));
repParent.DataSources = ds;
....
前台子repeater这样写
<repeater id= .... DataSources='<%#Eval("child")%>'>,,,,
dtParent.TableName = "parent";
DataTable dtChild = //table1_child 表里需要包含table1_Sid sid字段
dtChild.TableName = "child";
DataSet ds = new DataSet();
ds.Tables.Add(dtParent);
ds.Tables.Add(dtChild);
ds.Relations.Add(new DataRelation("child",dtParent.Columns["sid"],dtChild.Columns["sid这里是子表的外键"],false));
repParent.DataSources = ds;
....
前台子repeater这样写
<repeater id= .... DataSources='<%#Eval("child")%>'>,,,,
#5
頂!
#6
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%# Eval("ID")%>
<asp:Repeater ID="Repeater2" runat="server" DataSource='<%# GetDetails(Convert.ToInt32(Eval("ID"))) %>'>
<ItemTemplate>
<%#Eval("b")%>
</ItemTemplate>
</asp:Repeater>
<br />
</ItemTemplate>
</asp:Repeater>
protected DataTable GetDetails(int ID)
{
}
<ItemTemplate>
<%# Eval("ID")%>
<asp:Repeater ID="Repeater2" runat="server" DataSource='<%# GetDetails(Convert.ToInt32(Eval("ID"))) %>'>
<ItemTemplate>
<%#Eval("b")%>
</ItemTemplate>
</asp:Repeater>
<br />
</ItemTemplate>
</asp:Repeater>
protected DataTable GetDetails(int ID)
{
}
#1
protected void rpt_parentProduct_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
DataTable dt;
Repeater rpt = e.Item.FindControl("rpt_cateProduct") as Repeater;//找到嵌套的repearer
HtmlInputHidden hdparentid = e.Item.FindControl("hd_parentid") as HtmlInputHidden;//找个repeater1行的ID号 楼主的A
int companyid = logic.customer.getCompanyId();
int parentid = 0;
int.TryParse(hdparentid.Value, out parentid);
dt = DAL.DbHelper.ExecuteDataTable("P_category_select_SellerRange_smallCate", companyid, parentid);
rpt.DataSource = dt;
rpt.DataBind();
}
}
#2
顶!
#3
http://blog.csdn.net/greatverve/archive/2008/12/26/3600912.aspx
看看Repeater的嵌套用法。
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView drv = e.Item.DataItem as DataRowView;
Repeater child = e.Item.FindControl("rptChild") as Repeater;
child.DataSource = OleDbHelper.ExecuteDt("select * from type_2 where typeid_1 =" + drv["typeid_1"].ToString());
child.DataBind();
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/greatverve/archive/2008/12/26/3600912.aspx
drv["typeid_1"].ToString());这样得到。
看看Repeater的嵌套用法。
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView drv = e.Item.DataItem as DataRowView;
Repeater child = e.Item.FindControl("rptChild") as Repeater;
child.DataSource = OleDbHelper.ExecuteDt("select * from type_2 where typeid_1 =" + drv["typeid_1"].ToString());
child.DataBind();
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/greatverve/archive/2008/12/26/3600912.aspx
drv["typeid_1"].ToString());这样得到。
#4
DataTable dtParent = //table1_Sid
dtParent.TableName = "parent";
DataTable dtChild = //table1_child 表里需要包含table1_Sid sid字段
dtChild.TableName = "child";
DataSet ds = new DataSet();
ds.Tables.Add(dtParent);
ds.Tables.Add(dtChild);
ds.Relations.Add(new DataRelation("child",dtParent.Columns["sid"],dtChild.Columns["sid这里是子表的外键"],false));
repParent.DataSources = ds;
....
前台子repeater这样写
<repeater id= .... DataSources='<%#Eval("child")%>'>,,,,
dtParent.TableName = "parent";
DataTable dtChild = //table1_child 表里需要包含table1_Sid sid字段
dtChild.TableName = "child";
DataSet ds = new DataSet();
ds.Tables.Add(dtParent);
ds.Tables.Add(dtChild);
ds.Relations.Add(new DataRelation("child",dtParent.Columns["sid"],dtChild.Columns["sid这里是子表的外键"],false));
repParent.DataSources = ds;
....
前台子repeater这样写
<repeater id= .... DataSources='<%#Eval("child")%>'>,,,,
#5
頂!
#6
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%# Eval("ID")%>
<asp:Repeater ID="Repeater2" runat="server" DataSource='<%# GetDetails(Convert.ToInt32(Eval("ID"))) %>'>
<ItemTemplate>
<%#Eval("b")%>
</ItemTemplate>
</asp:Repeater>
<br />
</ItemTemplate>
</asp:Repeater>
protected DataTable GetDetails(int ID)
{
}
<ItemTemplate>
<%# Eval("ID")%>
<asp:Repeater ID="Repeater2" runat="server" DataSource='<%# GetDetails(Convert.ToInt32(Eval("ID"))) %>'>
<ItemTemplate>
<%#Eval("b")%>
</ItemTemplate>
</asp:Repeater>
<br />
</ItemTemplate>
</asp:Repeater>
protected DataTable GetDetails(int ID)
{
}