gridview不可见 [英] gridview is not visible

查看:107
本文介绍了gridview不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net网站上创建了gridview但是不可见

代码是:

i have created gridview in asp.net website but is not visible
the code is:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 

        AllowPaging="True" BackColor="White" BorderColor="#CC9966" BorderStyle="None" 

        BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource1" 

        ShowFooter="True">
        <rowstyle backcolor="White" forecolor="#330099" />
        <columns>
            <asp:TemplateField>
               
                <itemtemplate>
                    <asp:CheckBox ID="CheckBox1" AutoPostBack="true" runat="server" />
                </itemtemplate>
            
            <asp:BoundField DataField="company_id" HeaderText="company_id" ReadOnly="True" 

                SortExpression="company_id" />
            <asp:BoundField DataField="company_name" HeaderText="company_name" 

                SortExpression="company_name" />
            <asp:BoundField DataField="Company_add" HeaderText="Company_add" 

                SortExpression="Company_add" />
            <asp:BoundField DataField="Company_loc" HeaderText="Company_loc" 

                SortExpression="Company_loc" />
            <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
            <asp:BoundField DataField="country" HeaderText="country" 

                SortExpression="country" />
            <asp:BoundField DataField="zip" HeaderText="zip" SortExpression="zip" />
            <asp:BoundField DataField="phone" HeaderText="phone" SortExpression="phone" />
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            <asp:BoundField HeaderText="Site Id" ReadOnly="True" />
        </columns>
        <footerstyle backcolor="#FFFFCC" forecolor="#330099" />
        <pagerstyle backcolor="#FFFFCC" forecolor="#330099" horizontalalign="Center" />
        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />

推荐答案

首先检查天气方法是否填充数据表。在我的例子中,在代码的第2行声明一个调试点。如果您的DataTable为空,则不会显示gridview。



First check weather the method is filling data table or not. Declare a debug point on line 2 of code in my case. If your DataTable is empty than it will not show you gridview.

DataTable dataTable = new DataTable();
dataTable = gettingDataFromSomeMethod();

GridView1.DataSource = dataTable;
GridView1.DataBind();





你可以做的另一件事是将showHeader属性赋予gridview,所以至少你的标题会尽管你的数据表是否是空的,但仍然可见。





One more thing you can do is give ShowHeader attribute to gridview so atleast your header will be visible inspite of, whether your datatable is empty of filled.

<asp:gridview id="GridView1" runat="server" showheader="true" xmlns:asp="#unknown" />


这篇关于gridview不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆