protected void dlArea1_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("dlArea2"); int parentid = Convert.ToInt32(this.dlArea1.DataKeys[index].ToString()); DataTable subTable = country.getAreaList(parentid); dl.DataSource = subTable; dl.DataBind(); } } <asp:DataList ID="dlArea1" runat="server" DataKeyField="areaid" Width="500px" OnCancelCommand="dlArea1_CancelCommand" OnEditCommand="dlArea1_EditCommand" OnUpdateCommand="dlArea1_UpdateCommand" OnItemDataBound="dlArea1_ItemDataBound" OnDeleteCommand="dlArea1_DeleteCommand"> <ItemTemplate> <asp:LinkButton ID="lbtEdit" runat="server" Width="40px" CommandName="Edit">编辑</asp:LinkButton> <asp:LinkButton ID="lbtDel" runat="server" Width="40px" CommandName="Delete" OnClientClick="javascript:return confirm('你确定要删除这个代理地区吗?');">删除</asp:LinkButton> <asp:Label ID="lblCountryName" runat="server" Text='<%#Eval("cname") %>' CssClass="nameblue"></asp:Label> <asp:Label ID="lblArea1Name" runat="server" Text='<%# Eval("areaname") %>' Width="150px"></asp:Label> </ItemTemplate> <SeparatorTemplate> <div class="split1"> </div> </SeparatorTemplate> <ItemStyle Font-Bold="True" HorizontalAlign="Left" /> <EditItemTemplate> <asp:LinkButton ID="lbtUpdate" runat="server" CommandName="Update" Width="40px">更新</asp:LinkButton> <asp:LinkButton ID="lbtCancel" runat="server" CommandName="Cancel" Width="40px">取消</asp:LinkButton> <asp:DropDownList ID="ddlCountry" runat="server"> </asp:DropDownList> <asp:HiddenField ID="hfCountryName" runat="server" Value='<%#Eval("cname") %>' /> <asp:TextBox ID="tbAddr1" runat="server" Text='<%#Eval("areaname") %>' Width="100px"></asp:TextBox> </EditItemTemplate> </asp:DataList>