得到ID值?
如下代码:
<asp:DataList ID="ddlBig" runat="server" RepeatColumns="1" RepeatDirection="vertical" Width="100%">
<ItemTemplate>
<table width="100%" cellpadding="0" cellspacing="0" border="0" id='t<%#Container.ItemIndex + 1%>'>
<tr>
<td bgcolor="#a3d03f" align="right" height="30px" width="20%"><img src="images/icon11.jpg" width="9" height="5"> </td>
<td bgcolor="#a3d03f" align="left" height="30px" width="80%">
<a href="javascript:onclick=ShHi('t<%#Container.ItemIndex + 1%>','???');" class="white"><%#DataBinder.Eval(Container.DataItem,"bcname")%></a>
</td>
</tr>
</table>
<asp:DataList ID="ddlSmall" runat="server" DataSource='<%# GetTitleID(DataBinder.Eval(Container.DataItem, "bcid").ToString()) %>' RepeatColumns="1" RepeatDirection="vertical" Width="100%">
<ItemTemplate>
<table width="100%" cellpadding="0" cellspacing="0" border="0" id='h<%#Container.ItemIndex + 1%>'>
<tr>
<td bgcolor="#a3d03f" align="center" height="30px" width="200px"><%#DataBinder.Eval(Container.DataItem,"bsname") %></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
以上代码,我想在"???"这里获取到嵌套的datalist的展现到前台后的html的ID值..应该怎么写?谢谢!
------解决方案--------------------C# code
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
DataList ddlSmall = e.Item.FindControl("ddlSmall") as DataList;
string id=ddlSmall.ClientID;
}
}
------解决方案--------------------
FindControl就可以了啊