我在datagrid中建了个绑定列 绑定到数据库一个表中 然后把这个列转化为模板列 
在编辑中加入一个Dropdownlist 请问下 怎么把这个Dropdownlist绑定到数据库得另一个表上
谢谢!

解决方案 »

  1.   

    http://dev.csdn.net/develop/article/26/26590.shtm
      

  2.   

    http://www.cnblogs.com/lovecherry/archive/2005/03/25/125525.html
      

  3.   

    http://singlepine.cnblogs.com/articles/266538.html
      

  4.   

    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();
    }