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

瘦马 瘦马 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
数据库结构

nodeid 代码
name 名称
parentid 父ID


前台aspx文件

…………
<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#

protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
DropDownList drop = e.Row.FindControl("DropDownList1") as DropDownList;
…………//此处该如何写代码?
//将数据库中的树形数据绑定在DropDownList1中


}
...全文
评论 11
收藏 已收藏
分享
返回顶部
瘦马
.NET社区 62,272 成员 668,968 内容