I have two tables. One is for region and the other is f开发者_如何学编程or country. I want to show both in one listbox with checkbox.
There is no special control to render this type of relationship. However you can try to use standard CheckBoxList control. Children will be shifted a little using jquery. Maybe it is more elegant solution to shift cells using jquery.
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script language="javascript" type="text/javascript">
jQuery(document).ready(function () {
var cells = $('#<%= list.ClientID %>').find('td');
for (var i = 1; i < cells.length; i++) {
$(cells[i]).css('padding-left', '10px');
}
});
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:CheckBoxList id="list" runat="server">
<asp:ListItem>Parent</asp:ListItem>
<asp:ListItem>Child</asp:ListItem>
</asp:CheckBoxList>
</asp:Content>
You know that parent is first node, the rest are children.
精彩评论