如何在DataGird控件里,每行放一个DropDownList控件,达到如下效果
如DropDownList属性Items 2个值 “男”“女”
DataGird如下
姓名      座号        性别
1         001        “男”
2         002        “男”
3         003        “女”性别里是DropDownList控件请大家教教我,给我一段代码,详细解答
解决立刻给分
谢谢了,新年快乐

解决方案 »

  1.   

    <EditItemTemplate>
                <asp:DropDownList runat="server" ID="Dropdownlist1"/>
             </EditItemTemplate>
    http://www.microsoft.com/china/msdn/archives/library/dnaspp/html/creatingcustomcolumns.asp
      

  2.   

    在HTML你要的位置添加如下代码:
    <asp:TemplateColumn HeaderText="性别"> <HeaderStyle Wrap="False"></HeaderStyle>
    <ItemStyle Wrap="False"></ItemStyle>
    <ItemTemplate>
    <asp:Label id=label1 runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.性别") %>'>
    </asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:DropDownList id="xbddl" runat="server" Width="87px">
    <asp:ListItem Value="0">选择</asp:ListItem>
    <asp:ListItem Value="1">男</asp:ListItem>
    <asp:ListItem Value="2">女</asp:ListItem>
    </asp:DropDownList>
      </EditItemTemplate>
    </asp:TemplateColumn>或者直接在属性生成器里添加模板列,放控件即可~
      

  3.   

    不明白你说的意思 
    如果你是在DATAGRID的性别 栏显示 男女的话 不需要用DropDownList吧
      

  4.   

    在你的HTML代码里找到声明DataGrid的地方,添加:
    <asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 97px; POSITION: absolute; TOP: 59px" runat="server" Height="110px" Width="311px">
    <Columns>
    <asp:TemplateColumn HeaderText="性 别" HeaderStyle-HorizontalAlign="Center">
    <ItemTemplate>
    <asp:DropDownList id="cblSex" Runat="server">
    <asp:ListItem Value="0">选择</asp:ListItem>
    <asp:ListItem Value="0">男</asp:ListItem> <asp:ListItem Value="1">女</asp:ListItem>
    </asp:DropDownList>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>
      

  5.   

    在你的HTML代码里找到声明DataGrid的地方,添加:
    <asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 97px; POSITION: absolute; TOP: 59px" runat="server" Height="110px" Width="311px">
    <Columns>
    <asp:TemplateColumn HeaderText="性 别" HeaderStyle-HorizontalAlign="Center">
    <ItemTemplate> <asp:DropDownList id="cblSex" Runat="server">
    <asp:ListItem Value="0">选择</asp:ListItem>
    <asp:ListItem Value="0">男</asp:ListItem> <asp:ListItem Value="1">女</asp:ListItem> </asp:DropDownList>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>
      

  6.   

    <EditItemTemplate>
    <asp:DropDownList id="xbddl" runat="server" Width="87px">
    <asp:ListItem Value="0">选择</asp:ListItem>
    <asp:ListItem Value="1">男</asp:ListItem>
    <asp:ListItem Value="2">女</asp:ListItem>
    </asp:DropDownList>
      </EditItemTemplate>
    有问题请到群13827630 提问,论坛是bbs.shoucao.cn 提供控件源码下载
      

  7.   

    <EditItemTemplate>
    <asp:DropDownList id="xbddl" runat="server" Width="87px">
    <asp:ListItem Value="">选择</asp:ListItem>
    <asp:ListItem Value="1" checked=<%# DataBinder.Eval(Container,"DataItem.boolSex0") %>>男</asp:ListItem>
    <asp:ListItem Value="2" checked=<%# DataBinder.Eval(Container,"DataItem.boolSex1") %>>女</asp:ListItem>
    </asp:DropDownList>
      </EditItemTemplate>
    樓主的意思是在dataGrid裡放入dropdownlist,並且按照資料的返回值初始化,是這樣麼?你在存儲過程中返回:男則boolSex0 返回true,boolSex1 返回false
    反之則反,不知可不可以?
      

  8.   

    让我晕的是为什么不用
    RedioButtonList????