弄了一天,终于搞定
正确代码如下:
aspx代码如下: 最主要的是看子DataList的DataSource事件的绑定
<asp:DataList id="provincelist" runat="server" Width="770px">
<ItemTemplate>
<table width="770">
<tr>
<td height="31"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="2%" height="30"><div align="right"><img src="images/c_04_ico.gif" width="24" height="24" /></div>
</td>
<td width="98%" class="la13"> <a href='prolist.aspx?pro_id=<%# DataBinder.Eval(Container.DataItem,"provinceid") %>' class="la13" target=_blank>
<%# DataBinder.Eval(Container.DataItem,"provincename") %>
</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="27">
<asp:DataList id="citylist" runat="server" DataSource='<%# Getprovinceid(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "provinceid"))) %>' RepeatColumns="50" RepeatDirection="Horizontal"
RepeatLayout="Flow" Width="98%">
<ItemTemplate>
·<a href='province_1_18.html' title='澳门市大堂区' class="h"><%# DataBinder.Eval(Container.DataItem,"cityname") %></a>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
后台代码:
public DataView Getprovinceid(int provinceid)
{
DataSet qDs = qDAO.liebiaolist("add_city","cityid",provinceid,"provinceid");
return qDs.Tables[0].DefaultView;
}