treeview与数据库连接问题
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string connstr = ConfigurationManager.ConnectionStrings["SportsShoop"].ConnectionString;
string sql = "select e.typeName,d.sportsName,d.typeID,d.sportsID from SportsType e,SportsInfo d where e.typeID = d.typeID";
SqlDataAdapter adp = new SqlDataAdapter(sql,connstr);
DataSet ds = new DataSet();
adp.Fill(ds);
DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter = "parentId=0";
foreach(DataRowView drv in dv)
{
TreeNode root = new TreeNode(drv.Row["typeName"].ToString(), drv.Row["typeID"].ToString());
this.TreeView1.Nodes.Add(root);
}
for (int i = 0; i < this.TreeView1.Nodes.Count; i++)
{
this.AddChildNode(ds, this.TreeView1.Nodes[i]);
}
}
}
我的数据库表中没有parentId,联合查询之后的表,dv.RowFilter = "parentId=0"; 这段怎么写?