<asp:datagrid id="DataGrid1" runat="server" PageSize="5" AllowPaging="True" CellPadding="5" BackColor="White"
BorderWidth="5px" BorderStyle="None" BorderColor="#3366CC" HorizontalAlign="Center" Height="400px" AutoGenerateColumns="False"
Width="560px">
<SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedItemStyle>
<ItemStyle ForeColor="#003399" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#CCCCFF" BackColor="#99CCCC"></HeaderStyle>
<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="ID" HeaderText="ID" ReadOnly=True></asp:BoundColumn>
<asp:BoundColumn DataField="NAME" HeaderText="分类名称"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="所属大类">
<ItemTemplate>
<asp:DropDownList ID="dpl_FirstCatalog" Runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="首页显示">
<ItemTemplate>
<asp:RadioButtonList Runat="server" ID="rbl_IsShow">
<asp:ListItem Value="1">是</asp:ListItem>
<asp:ListItem Value="0">否</asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="更新" CancelText="取消" EditText="编辑"></asp:EditCommandColumn>
<asp:ButtonColumn Text="选择" CommandName="Select"></asp:ButtonColumn>

</Columns>
<PagerStyle HorizontalAlign="Right" ForeColor="#003399" BackColor="#99CCCC" Mode="NumericPages"></PagerStyle>
</asp:datagrid>

解决方案 »

  1.   

    最好复制下来用文本看,这是datagrid的
      

  2.   

    没有数据是因为你没有绑定数据源;
    要放入控件的话,设置几个模板列,然后Gridview上右键->编辑模板->你要编辑的模板
    直接拖控件进去好了
      

  3.   

    不是没有数据的问题 我现在的问题是在页面上不显示Gridview的表格形式 正常的话 就算没有数据在运行的时候 不也得有空表格出现 对吧 最起码有标题出现 现在是什么都没有! 这个问题实现了 然后解决数据绑定的问题!
      

  4.   

    用的是VS 2005上面没有Datagrid的控件了! 郁闷 不过还是谢谢大家  要是谁有的网站介绍也行 谢谢你们!
      

  5.   

    我正在用gridview 这事VS2005自动生成的前台代码:  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" Width="710px" >
                <Columns>
                    <asp:BoundField DataField="product_id" HeaderText="ID" SortExpression="product_id" />
                    <asp:BoundField DataField="product_name" HeaderText="产品名称" >
                        <ItemStyle HorizontalAlign="Center" Width="100px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="product_price" HeaderText="产品价格" SortExpression="product_price" />
                    <asp:BoundField DataField="product_description" HeaderText="产品描述" SortExpression="product_description" />
                    <asp:BoundField DataField="product_supplier_id" HeaderText="供应商编号" SortExpression="produc _supplier_id" />
                    <asp:BoundField DataField="product_quantity" HeaderText="数量" SortExpression="product_stock_id" />
                    <asp:BoundField DataField="product_on_sale" HeaderText="是否有售" SortExpression="product_on_sale" />
                    <asp:TemplateField HeaderText="操作 ">
                        <ItemTemplate>
                            <a onclick='js_del(<%# DataBinder.Eval(Container,"DataItem.product_id") %>)'>删除</a>
                            <a onclick='js_edit(<%# DataBinder.Eval(Container,"DataItem.product_id") %>)'>修改 </a>
                        </ItemTemplate>
                    </asp:TemplateField>
                   
                </Columns>
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <EditRowStyle BackColor="#999999" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:GridView>
    后台代码:protected void Page_Load(object sender, EventArgs e)
        {  //第一次执行加载的代码
            if (!IsPostBack)
            {
                int _id = Convert.ToInt32(Request["id"]);
                _txt_id.Text = _id.ToString();            _min.Text = "";
                _max.Text = "";            Product.BLL.Product _bp = new Product.BLL.Product();
                string _ret = "";
                if (PubLib.Oxox.ConvertToDecimal(_min.Text.ToString()) == PubLib.Oxox.ConvertToDecimal(_max.Text.ToString())) { GridView1.DataSource = _bp.GetList(TextBox1.Text.ToString(), _pd.Text.ToString(), ref _ret); }
                else GridView1.DataSource = _bp.GetList(TextBox1.Text.ToString(), PubLib.Oxox.ConvertToDecimal(_min.Text.ToString()), PubLib.Oxox.ConvertToDecimal(_max.Text), _pd.Text.ToString(), ref _ret);
                GridView1.DataBind();
               
            }
    "把其中的一列变成DropDownList那种形式也就是带有下拉栏的形式 其中的两列变成CheckBox"这样:把你选定的列改为模板列,从工具箱托一个DropDownList或者Checkbox                    前台代码:<%# xxx(DataBinder.Eval(Container.DataItem,"字段名").ToString())%>
    后台代码:private xxx (object params){ //todo}
      

  6.   

    现在还是那个问题 数据传上去了 可就是在网页上不显示 不是不显示数据 就是整个gridview控件的表格形式都不显示 我快疯了 代码不是写在MultiView里吗 为什么会出现这样的问题呢 真奇怪 看来今晚上得很晚回家了!大家帮帮我吧
      

  7.   

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:DropDownList ID="DropDownList2" runat="server">
                            </asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox2" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
      

  8.   

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="C0100.aspx.vb" Inherits="frm_C0100" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>新SFA</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div style="color: #3333ff;">
            &nbsp;<br />
            &nbsp;
            
           <asp:Menu
            ID="Menu1"
            Width="128px"
            runat="server"
            Orientation="Horizontal"
            StaticEnableDefaultPopOutImage="False"
            OnMenuItemClick="Menu1_MenuItemClick">
        <Items>
            <asp:MenuItem Text="Myボータル" Value="0"></asp:MenuItem>
            <asp:MenuItem Text="情報" Value="1"></asp:MenuItem>
        </Items>   
    </asp:Menu>
    <asp:MultiView 
        ID="MultiView1"
        runat="server"
        ActiveViewIndex="0"  >
       <asp:View ID="Tab1" runat="server"  >
            <table width="1000" height="600px" cellpadding="0" cellspacing="0">
                <tr valign="top">
                    <td class="TabArea" style="width: 892px">
                       <br />
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<asp:Label ID="Label1" runat="server" Text="市販直後調査一括入力" Width="400px" BackColor="PowderBlue" Font-Bold="True" ForeColor="Black"></asp:Label><br />
            <br />
            案件 &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
            <select id="Category" size=1 style="width: 336px">
                              <option>psychology</option>
                              <option>business</option>
                              <option>popular_comp</option>
                          </select>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;
                     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;  &nbsp; &nbsp;
                        <asp:Button ID="Button2" runat="server" Text="クリア" Width="64px" /><asp:Button ID="Button3"
                runat="server" Text="登録" Width="64px" /><br />
            <br />
            施設担当者&nbsp; 
            <select id="Select1" size=1 style="width: 104px">
                              <option>psychology</option>
                              <option>business</option>
                              <option>popular_comp</option>
                          </select>
                          <select id="Select2" size=1 style="width: 104px">
                              <option>psychology</option>
                              <option>business</option>
                              <option>popular_comp</option>
                          </select>
                          <select id="Select3" size=1 style="width: 104px">
                              <option>psychology</option>
                              <option>business</option>
                              <option>popular_comp</option>
                          </select>
                          <select id="Select4" size=1 style="width: 104px">
                              <option>psychology</option>
                              <option>business</option>
                              <option>popular_comp</option>
                          </select>&nbsp;&nbsp &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
             対象薬剤: エビリファイ
            <br />
            <br />
            施設ランク &nbsp;&nbsp;
            <asp:CheckBox ID="CheckBox1" runat="server" ForeColor="Black" Text="HP1" />
            &nbsp;
            <asp:CheckBox ID="CheckBox2" runat="server" ForeColor="Black" Text="HP2" />
            &nbsp;
            <asp:CheckBox ID="CheckBox3" runat="server" ForeColor="Black" Text="HP3" />
            &nbsp;
            <asp:CheckBox ID="CheckBox4" runat="server" ForeColor="Black" Text="GP1" />
            &nbsp;
            <asp:CheckBox ID="CheckBox5" runat="server" ForeColor="Black" Text="GP2" />
            &nbsp;
            <asp:CheckBox ID="CheckBox6" runat="server" ForeColor="Black" Text="GP3" />
            &nbsp;
            <asp:CheckBox ID="CheckBox7" runat="server" ForeColor="Black" Text="GP他" /><br />
            <br />
            面談予定日&nbsp;&nbsp; &nbsp;
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
           &nbsp;&nbsp;
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
            <asp:Button ID="Button4" runat="server" Text="検索" Width="80px" />&nbsp;      
            <asp:Button ID="Button5" runat="server" Text="CSV出力" Width="80px" /><br />
                        <br />
                        <asp:GridView AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" Height="168px" ID="GridView1" runat="server" Width="984px" >
                            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                            <Columns>
                                <asp:BoundField HeaderText="No." />
                                <asp:BoundField HeaderText="担当者" />
                                <asp:BoundField HeaderText="ランク" />
                                <asp:BoundField HeaderText="施設名" />
                                <asp:BoundField HeaderText="診療科" />
                                <asp:BoundField HeaderText="Dr名" />
                                <asp:TemplateField HeaderText="面談予定日"></asp:TemplateField>
                                <asp:BoundField HeaderText="初回納入日" />
                                <asp:BoundField HeaderText="自動" />
                                <asp:BoundField HeaderText="面談日" />
                                <asp:BoundField HeaderText="面談目的" />
                                <asp:CheckBoxField HeaderText="面談" />
                                <asp:CheckBoxField HeaderText="訪問" />
                                <asp:BoundField HeaderText="特記事項" />
                            </Columns>
                            <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                            <AlternatingRowStyle BackColor="Gainsboro" />
                        </asp:GridView>
                    </td>
                </tr>
            </table>
         </asp:View>
             <asp:View ID="Tab2" runat="server">
            <table width="1000" cellpadding=0 cellspacing=0>
                <tr valign="top">
                    <td class="TabArea" style="width: 600px">
                    <br />
                    <br />
                     TAB VIEW 2hgjhgjhgjgjh
                      trewertwertwertwe
                    </td>
                </tr>
            </table>
            </asp:View></asp:MultiView>
        </div>
        </form>
    </body>
    </html>
    谢谢你楼上! 你帮我看看 这只是最初期的想要得画面! 可是运行的时候就是显示不出来 只显示上面的部分!
      

  9.   

    我记得是如果没有数据的话就会什么都不会显示,包括已经绑定了的字段名也不会显示。我是菜鸟````说的不对,不要介意。随便问个问题,为什么2005没有DATAGRID???????
      

  10.   

    没有数据绑定吧,肯定gridview不会显示出来的
    或者你可以手动添加一空行,你改成vb的就行
    if (!IsPostBack)
            {
                DataTable dt = new DataTable();
                dt.Rows.Add(dt.NewRow());
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
      

  11.   

    没有数据绑定就显示不出来数据哈 那么就在我原先的代码上 手动加一条数据 试试看,呵呵 别改成VB 还是用Asp.Net 该怎么手动加呢 谢谢楼上 嘿嘿!
      

  12.   

    你应该看看它的属性生成器,还有数据绑定到grideview并且执行了才能显示
      

  13.   

    用的是VS 2005上面没有Datagrid的控件了! 郁闷 不过还是谢谢大家  要是谁有的网站介绍也行 谢谢你们!
    --------------------------------------------------------------
    没有显示出来,但支持,你在里面写 <asp:Datagrid ...一样的
      

  14.   

    问大家一个白痴的问题哈,从数据源导出的数据想显示在gridview中,现在 gridview其中有一列设置成DropDownList属性,这样的话 (其他的都是BoundField属性的)从数据源导出的数据可以直接显示到设置成DropDownList属性的这一列吗? 会不会出错!因为我现在还没有数据源 所以不能做例子 所以担心这个问题 谢谢大家帮我 祝你们开心!
      

  15.   

    网络技术高级群“31868295”欢迎你的加入! 
    讨论话题:CISCO、WINDOWS2003、SQL、EXCHANGE、LINUX、网络信息安全、Windows和Linux系统上的各种服务器的搭建!来者请注名
      

  16.   

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:DropDownList ID="DropDownList2" runat="server">
                            </asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox2" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>这段代码实现了我在gridview里其中的三列设置成checkbox和dropdownlist类型,我现在还想设置成 TableCell类型,在上面的代码上直接把checkbox改成TableCell为什么不行?该怎么实现呢!谢谢大家帮我 紫色阴影 上面的代码就是你写的 谢谢你!现在这个新问题该怎么解决!
      

  17.   

    楼主去搜索一下这文章对你一定有帮助,他可以解决你上面所有的问题
    C#精髓【月儿原创】第四讲 GridView 72般绝技 - 清清月儿
      

  18.   

    tablecell要有table才行
    比如:
            <asp:GridView ID="GridView1" runat="server">
                <EmptyDataTemplate>
                    <asp:Table ID="Table1" runat="server">
                        <asp:TableRow>
                            <asp:TableCell></asp:TableCell>
                        </asp:TableRow>
                    </asp:Table>
                </EmptyDataTemplate>
            </asp:GridView>