<SelectedItemTemplate>
<asp:DataList ID="DL_SCate" runat="server" Width="100%" DataSource='<%#((System.Data.DataRowView)Container.DataItem).CreateChildView("SmallCateView") %>'>
<ItemTemplate>
<asp:LinkButton ID="SCate" runat="server" Text='<%# Eval("SC_Name")%>' BackColor="#F1F0EE"
PostBackUrl='<%# Eval("SC_ID","~/CateDetails.aspx?SID={0}") %>' Font-Size="Small"></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
</SelectedItemTemplate>
<ItemTemplate>
<asp:LinkButton Font-Underline="false" ForeColor="#003399" ID="Cate" runat="server"
Text='<%# "* "+Eval("CateName")%>' CommandName="select"
CommandArgument='<%# Eval("CateID") %>' Font-Size="XX-Large" Font-Bold="true"></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
{
if (e.CommandName == "select")
{
this.DL_Cate.SelectedIndex = e.Item.ItemIndex;
DL_Cate.DataSource = p_access.GetReView().Tables[0].DefaultView;
DL_Cate.DataBind();
}
}
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Web;
{
public class DataAccess
{
public DataSet GetReView()
{
string sql = "IndexCate";
da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);
//设置数据集中两个表的名称
ds.Tables[0].TableName = "Cate";
ds.Tables[1].TableName = "SmallCate";
//父
DataColumn a = ds.Tables["Cate"].Columns["CateID"];
//子
DataColumn b = ds.Tables["SmallCate"].Columns["CateID"];
//创建关系对象
DataRelation drt = new DataRelation("SmallCateView", a, b, false);
//为dataset中的关系集合添加关系对象
ds.Relations.Add(drt);
return ds;
}
}
}