要自己写从DropDownList继承的控件把,asp.net自带的DropDownList好像达不到这个效果

解决方案 »

  1.   

    答案是肯定的;你的表里是有标识的,这样加起来不难,往下拉表里加的时后,先把前面的制表符加上再放进去,asp.net也是有HTML控件的,服务器的控件你搞不出来,你就用HTML的搞下,会ASP的人最通这个.
      

  2.   

    当初这个模式就是我用ASP做出来的,现在要转.net平台,这块都不知道怎么处理了,
    难道这一小块用asp 最后在HTML表单中加个 runat="server" ?  如果不想用ASP语言,就想用.net 
    实现起来是不是难度很大?
      

  3.   

            public static ListItem[] GetTSpecialTree()
            {
                List<ListItem> Result = new List<ListItem>();
                Result.Add(new ListItem("---请选择---", "-1"));            usp_TSpecial_ByAll usp = new usp_TSpecial_ByAll();  
                DataTable dt = usp.ExecDataTable();
                DataRow[] dr = dt.Select("IsEnabled = 0");            for (int i = 0; i < dr.Length; i++)
                {
                    string Separator = "├—";
                    string Text = dr[i]["Name"].ToString().Trim();
                    string Value = dr[i]["SpecialID"].ToString().Trim();
                    Result.Add(new ListItem(Text, Value));
                    BindNode(ref Result, Value, dt, Separator);
                }
                return Result.ToArray();
            }
            private static void BindNode(ref List<ListItem> listItemCollection, string parentId, DataTable dt, string separator)
            {
                DataRow[] dr = dt.Select("IsEnabled=" + parentId);
                for (int i = 0; i < dr.Length; i++)
                {
                    if (i + 1 == dr.Length)
                    {
                        separator = separator.Replace("├—", "└—");
                    }
                    string Text = separator + dr[i]["Name"].ToString().Trim();
                    string Value = dr[i]["SpecialID"].ToString().Trim();
                    listItemCollection.Add(new ListItem(Text, Value));
                    if (i + 1 == dr.Length)
                    {
                        separator = separator.Replace("└—", "├—");
                    }
                    BindNode(ref listItemCollection, Value, dt, System.Web.HttpUtility.HtmlDecode("┆&nbsp;&nbsp;&nbsp;") + separator);
                    //"││┃┆┊┋";                
                }
            }
    你改改就能用了,你的DropDownList1.Items.AddRange(NewsRule.GetTSpecialTree())就可以载入了
      

  4.   

    <asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:MySqlProviderConnection %>"
                SelectCommand="SELECT 0 AS WareHouseID,'所有仓库' AS Description, 'NULL->0' AS Label Union SELECT [WareHouseID], REPLICATE ('|- ', [Level]) + [Description] AS Description, Label FROM dbo.GetWareHouseTreeInfo() order by [Label]"></asp:SqlDataSource>
            <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource6"
                DataTextField="Description" DataValueField="WareHouseID">
            </asp:DropDownList>
      

  5.   

    public static ListItem[] GetTSpecialTree() 
            { 
                List <ListItem> Result = new List <ListItem>(); 
                Result.Add(new ListItem("---请选择---", "-1"));             usp_TSpecial_ByAll usp = new usp_TSpecial_ByAll();  
                DataTable dt = usp.ExecDataTable(); 
                DataRow[] dr = dt.Select("IsEnabled = 0");             for (int i = 0; i < dr.Length; i++) 
                { 
                    string Separator = "├—"; 
                    string Text = dr[i]["Name"].ToString().Trim(); 
                    string Value = dr[i]["SpecialID"].ToString().Trim(); 
                    Result.Add(new ListItem(Text, Value)); 
                    BindNode(ref Result, Value, dt, Separator); 
                } 
                return Result.ToArray(); 
            } 
            private static void BindNode(ref List <ListItem> listItemCollection, string parentId, DataTable dt, string separator) 
            { 
                DataRow[] dr = dt.Select("IsEnabled=" + parentId); 
                for (int i = 0; i < dr.Length; i++) 
                { 
                    if (i + 1 == dr.Length) 
                    { 
                        separator = separator.Replace("├—", "└—"); 
                    } 
                    string Text = separator + dr[i]["Name"].ToString().Trim(); 
                    string Value = dr[i]["SpecialID"].ToString().Trim(); 
                    listItemCollection.Add(new ListItem(Text, Value)); 
                    if (i + 1 == dr.Length) 
                    { 
                        separator = separator.Replace("└—", "├—"); 
                    } 
                    BindNode(ref listItemCollection, Value, dt, System.Web.HttpUtility.HtmlDecode("┆&nbsp;&nbsp;&nbsp;") + separator); 
                    //"││┃┆┊┋";                
                } 
            }