datalist嵌套datalist,第二层datalist为隐藏层,急!!
我做一个datalist嵌套,第二层默认隐藏,当点击第一层中的一个标题时,弹出对应的隐藏层信息,请问要怎么做,我自己弄的代码能实现弹出效果,但是点击时,出来的总是第一个标...
我做一个datalist嵌套,第二层默认隐藏,当点击第一层中的一个标题时,弹出对应的隐藏层信息,请问要怎么做,我自己弄的代码能实现弹出效果,但是点击时,出来的总是第一个标题的隐藏层,求助ing
代码如下:
<script type="text/javascript" language="javascript">
function DIVShow(i){
if( document.getElementById(i).style.display=='')
document.getElementById(i).style.display = 'none';
else
document.getElementById(i).style.display = '';
}
</script>
<div class="show" >
<asp:DataList ID="dl1" RepeatDirection="Horizontal" runat="server"
RepeatColumns="20" onitemdatabound="dl1_ItemDataBound" DataKeyField="code" >
<ItemTemplate>
<asp:HyperLink runat="server" NavigateUrl='#' Target="_blank">
<a href="javascript:DIVShow('hidden')"><%#Eval("name") %></a><br />
<div style="display:none;" id="hidden" class="hidden">
<h2><a onclick="javascript:document.getElementById('hidden').style.display='none';" class="red" href="#">[关闭层]</a>隐藏层</h2>
<asp:DataList ID="dl2" RepeatDirection="Horizontal" runat="server" RepeatColumns="5" >
<ItemTemplate>
<asp:HyperLink runat="server" NavigateUrl='#' Target="_blank" Text='<%#Eval("name") %>'>
</asp:HyperLink>
</ItemTemplate>
</asp:DataList>
</div>
</asp:HyperLink>
</ItemTemplate>
</asp:DataList>
</div>
后台:
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = FC.BLL.LinkToBLL.GetProvince();
this.dl1.DataSource = ds;
this.dl1.DataBind();
}
protected void dl1_ItemDataBound(object sender, DataListItemEventArgs e)
{
int index = e.Item.ItemIndex;
if (e.Item.ItemType == ListItemType.Item||e.Item.ItemType == ListItemType.AlternatingItem)
{
DataList dl = (DataList)e.Item.FindControl("dl2");
string id = this.dl1.DataKeys[index].ToString();
DataRowView rowv = (DataRowView)e.Item.DataItem;
string mainID = rowv["code"].ToString();
DataSet dss = FC.BLL.LinkToBLL.GetCity(mainID);
dl.DataSource = dss;
dl.DataBind();
}
} 展开
代码如下:
<script type="text/javascript" language="javascript">
function DIVShow(i){
if( document.getElementById(i).style.display=='')
document.getElementById(i).style.display = 'none';
else
document.getElementById(i).style.display = '';
}
</script>
<div class="show" >
<asp:DataList ID="dl1" RepeatDirection="Horizontal" runat="server"
RepeatColumns="20" onitemdatabound="dl1_ItemDataBound" DataKeyField="code" >
<ItemTemplate>
<asp:HyperLink runat="server" NavigateUrl='#' Target="_blank">
<a href="javascript:DIVShow('hidden')"><%#Eval("name") %></a><br />
<div style="display:none;" id="hidden" class="hidden">
<h2><a onclick="javascript:document.getElementById('hidden').style.display='none';" class="red" href="#">[关闭层]</a>隐藏层</h2>
<asp:DataList ID="dl2" RepeatDirection="Horizontal" runat="server" RepeatColumns="5" >
<ItemTemplate>
<asp:HyperLink runat="server" NavigateUrl='#' Target="_blank" Text='<%#Eval("name") %>'>
</asp:HyperLink>
</ItemTemplate>
</asp:DataList>
</div>
</asp:HyperLink>
</ItemTemplate>
</asp:DataList>
</div>
后台:
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = FC.BLL.LinkToBLL.GetProvince();
this.dl1.DataSource = ds;
this.dl1.DataBind();
}
protected void dl1_ItemDataBound(object sender, DataListItemEventArgs e)
{
int index = e.Item.ItemIndex;
if (e.Item.ItemType == ListItemType.Item||e.Item.ItemType == ListItemType.AlternatingItem)
{
DataList dl = (DataList)e.Item.FindControl("dl2");
string id = this.dl1.DataKeys[index].ToString();
DataRowView rowv = (DataRowView)e.Item.DataItem;
string mainID = rowv["code"].ToString();
DataSet dss = FC.BLL.LinkToBLL.GetCity(mainID);
dl.DataSource = dss;
dl.DataBind();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询