none
在GridView模板列内的DropDownList,如何绑定树形数据 RRS feed

  • 问题

  • 数据库结构

    nodeid 代码
    name 名称
    parentid 父ID


    前台aspx文件
    HTML code
    ………… <form id="form1" runat="server"> <asp:GridView ID="GridView1" RowDataBound="GridView1_RowDataBound" runat="server" AutoGenerateColumns="False"> <Columns> <asp:BoundField HeaderText="第一列" /> <asp:BoundField HeaderText="第二列" /> <asp:BoundField HeaderText="第三列" /> <asp:BoundField HeaderText="第四列" /> <asp:BoundField HeaderText="第五列" /> <asp:TemplateField HeaderText="模板列"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"runat="server"></asp:DropDownList> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </form> …………


    后台C#
    C# code
    
    protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
       {
           DropDownList drop = e.Row.FindControl("DropDownList1") as DropDownList;
          …………//此处该如何写代码?
    //将数据库中的树形数据绑定在DropDownList1中
    
           
       }
    2012年9月29日 0:30

答案