<asp:DataList ID="Dlt_Class" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" BorderColor="White" EnableTheming="True" Height="422px" Width="736px"> <ItemTemplate>
<table style="width: 242px; border-right: lime 3px double; border-top: lime 3px double; border-left: lime 3px double; border-bottom: lime 3px double;">
<tr>
<td style="width: 223px; font-weight: bold; font-size: 10pt;" align="center">
<a href="ClassType.aspx?id=<%# Eval("PKID") %>&twoid=<%# Eval("UPID") %>"><%# DataBinder.Eval(Container.DataItem, "ClassName")%></a>
</td>
</tr>
<tr>
<td style="width: 223px; height: 73px;">
<asp:DataList id="childDataList" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" datasource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("myrelation") %>'> /////下面的无法绑定
<HeaderTemplate>
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>
</HeaderTemplate>
<itemtemplate>
<a href="ClassType.aspx?id=<%# Eval("[\"PKID\"]") %>&twoid=<%# Eval("[\"UPID\"]") %>"><%# DataBinder.Eval(Container.DataItem, "[\"ClassName\"]")%></a>
</itemtemplate>
<FooterTemplate>
</td>
</tr>
</table>
</FooterTemplate>
</asp:DataList></td>
</tr>
</table>
</ItemTemplate>
<ItemStyle VerticalAlign="Top" />
</asp:DataList>
页面只显示大类的名称 大类下面的子类都无法显示
后台代码
public void Bind()
{
string strSQL,strSQL1, strSQL2;
strSQL1 = "select * from t_sj_ClassInfo where UPID=0 ";
strSQL2 = "select * from t_sj_ClassInfo where UPID<>0 ";
strSQL = strSQL1 + ";" + strSQL2;
DataSet ds = GetDataSet(strSQL);
ds.Relations.Add("myrelation", ds.Tables[0].Columns["PKID"], ds.Tables[1].Columns["PKID"],false);
Dlt_Class.DataSource = ds.Tables[0];
Dlt_Class.DataBind();
}public static DataSet GetDataSet(string sql)
{
SqlDataAdapter da = null;
DataSet ds = new DataSet();
int i = 1;
string[] strSqls = sql.Split(';');
foreach (string strSql in strSqls)
{
da = GetAdapter(strSql);
da.Fill(ds, "table" + i.ToString());
i++;
} return ds;
}
public static SqlDataAdapter GetAdapter(string sql)
{
SqlDataAdapter da = new SqlDataAdapter((SqlCommand)GetCommand(sql));
return da;
}
public static IDbCommand GetCommand(string sql)
{
IDbCommand cmd = new SqlCommand(sql, (SqlConnection)GetConnection());
return cmd;
}
public static IDbConnection GetConnection()
{
IDbConnection cnn = new SqlConnection(ConfigurationManager.AppSettings["dbConnStr"]);
return cnn;
} 数据库如下
PKID ClassName UPID code
1 水果 0 0001
2 苹果 1 00010001
3 香蕉 1 00010002
4 家电 0 0002
5 彩电 4 00020001期待各位的答复
解决方案 »
- 开源:视频语音 实时传输 网络版 支持所有带摄像头的windows 电脑、笔记本、各种外置摄像头
- flashfxp在上传过一次后,为什么不能再以同样的文件名上传了
- 数据库语句问题.急~~~~~~急着要跳楼拉~
- 求教,下面格式的序列怎么解析
- 访问oracle存储过程,出现如下错误,怎样解决?谢谢!
- asp.net中TreeView1的问题
- reapter一放到table里,在DW里整个页面就乱了,但显示还是正常的,怎么会事???50分!!!
- pageddatasource 的分页类在独立的类库中怎样创建对象
- 等待
- 这个语句是什么意思?
- 请问在net.asp中如何页面a.aspx中如何引用另一页top.aspx
- 在线客服系统实现原理
{
string strSQL,strSQL1, strSQL2;
strSQL1 = "select * from t_sj_ClassInfo where UPID=0 ";
strSQL2 = "select * from t_sj_ClassInfo where UPID<>0 ";
strSQL = strSQL1 + ";" + strSQL2;
DataSet ds = GetDataSet(strSQL);
Dlt_Class.DataSource = ds.Tables[0];
Dlt_Class.DataBind();
childDataList.DataSource=ds.Tables[1];
childDataList.DataBind();
}public static DataSet GetDataSet(string sql)
{
DataSet ds = new DataSet();
SqlDataAdapter da = GetAdapter(strSql);
da.Fill(ds);
return ds;
}
嵌套在里面的 你能把childDataList直接拿出来绑定?? 你试下你写的看能通过不?