datalist两级嵌套,如我在datalist1中嵌套了datalist2,我还想在datalist2中再嵌套一个datalist3。
protectedvoidDataList3_ItemDataBound(objectsender,DataListItemEventArgse){stringsfid=...
protected void DataList3_ItemDataBound(object sender, DataListItemEventArgs e)
{
string sfid = this.DataList3.DataKeys[e.Item.ItemIndex].ToString();
if (Request.QueryString["id"] == null)
{
DataList dl = e.Item.FindControl("DataList4") as DataList;
DataSet ds4 = sq.Getsqlindex("spview", "spid", "", 0, "sfid=" + sfid + " and swid = 1");
dl.DataSource = ds4;
dl.DataBind();
}
else
{
string swid = Request.QueryString["id"].ToString();
DataList dl = e.Item.FindControl("DataList4") as DataList;
DataSet ds4 = sq.Getsqlindex("spview ", "spid", "", 0, "sfid=" + sfid + " and swid = " + swid + " and issh = 1");
dl.DataSource = ds4;
dl.DataBind();
}
}
这个可以实现一层嵌套,我想在datalist4中再嵌套一个,怎么实现,怎么绑定,求解!谢谢。 展开
{
string sfid = this.DataList3.DataKeys[e.Item.ItemIndex].ToString();
if (Request.QueryString["id"] == null)
{
DataList dl = e.Item.FindControl("DataList4") as DataList;
DataSet ds4 = sq.Getsqlindex("spview", "spid", "", 0, "sfid=" + sfid + " and swid = 1");
dl.DataSource = ds4;
dl.DataBind();
}
else
{
string swid = Request.QueryString["id"].ToString();
DataList dl = e.Item.FindControl("DataList4") as DataList;
DataSet ds4 = sq.Getsqlindex("spview ", "spid", "", 0, "sfid=" + sfid + " and swid = " + swid + " and issh = 1");
dl.DataSource = ds4;
dl.DataBind();
}
}
这个可以实现一层嵌套,我想在datalist4中再嵌套一个,怎么实现,怎么绑定,求解!谢谢。 展开
1个回答
展开全部
一样的啊
你在datalist4的ItemDataBound里面写上面的代码就可以了
你在datalist4的ItemDataBound里面写上面的代码就可以了
更多追问追答
追问
可是datalist4在datalist3中嵌套着,后台找不到这个控件的啊。
追答
protected void DataList3_ItemDataBound(object sender, DataListItemEventArgs e)
{
string sfid = this.DataList3.DataKeys[e.Item.ItemIndex].ToString();
if (Request.QueryString["id"] == null)
{
DataList dl = e.Item.FindControl("DataList4") as DataList;
dl.ItemDataBound+=new DataListItemEventHandler(DataListnew_ItemDataBound);
DataSet ds4 = sq.Getsqlindex("spview", "spid", "", 0, "sfid=" + sfid + " and swid = 1");
dl.DataSource = ds4;
dl.DataBind();
}
else
{
string swid = Request.QueryString["id"].ToString();
DataList dl = e.Item.FindControl("DataList4") as DataList;
dl.ItemDataBound+=new DataListItemEventHandler(DataListnew_ItemDataBound);
DataSet ds4 = sq.Getsqlindex("spview ", "spid", "", 0, "sfid=" + sfid + " and swid = " + swid + " and issh = 1");
dl.DataSource = ds4;
dl.DataBind();
}
}
protected void DataListnew_ItemDataBound(object sender, DataListItemEventArgs e)
{
//do something
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询