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中再嵌套一个,怎么实现,怎么绑定,求解!谢谢。
展开
 我来答
百度网友e1abcca7
2013-03-18 · TA获得超过163个赞
知道小有建树答主
回答量:372
采纳率:100%
帮助的人:204万
展开全部
一样的啊
你在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

}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式