急 急

BNFlying 2005-12-02 03:03:08
我在datagrid中建了个绑定列 绑定到数据库一个表中 然后把这个列转化为模板列
在编辑中加入一个Dropdownlist 请问下 怎么把这个Dropdownlist绑定到数据库得另一个表上
谢谢!
...全文
121 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChengKing 2005-12-02
  • 打赏
  • 举报
回复
1.*.aspx文件
<ItemTemplate>
<asp:Label id=Label2 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.状态") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate> <asp:DropDownList id="DropDownList1" runat="server" Width="78px" SelectedIndex='<%# GetStatusIndex(DataBinder.Eval(Container,"DataItem.状态").ToString())%>'>
<asp:ListItem Value="未完成">未完成</asp:ListItem>
<asp:ListItem Value="完成">完成</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
2. *.cs文件代码(一般只有这个事件中用到取值)
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DropDownList dpdAreas=(DropDownList)e.Item.FindControl("DropDownList1");
this.dpdAreas.DataTextField = "AreaName";
this.dpdAreas.DataValueField = "AreaID";
this.dpdAreas.DataSource = DS;
this.dpdAreas.DataBind();
}
singlepine 2005-12-02
  • 打赏
  • 举报
回复
http://singlepine.cnblogs.com/articles/266538.html
ZeroGong 2005-12-02
  • 打赏
  • 举报
回复
同意楼上
jiang8282 2005-12-02
  • 打赏
  • 举报
回复
http://www.cnblogs.com/lovecherry/archive/2005/03/25/125525.html
jiang8282 2005-12-02
  • 打赏
  • 举报
回复
http://dev.csdn.net/develop/article/26/26590.shtm

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧