首页 新闻 赞助 找找看

嵌套在div中的gridview无法在浏览器中显示出来,也没报错。

0
悬赏园豆:5 [已解决问题] 解决于 2013-03-13 16:21
<div class="lanmu">项 目 列 表</div>
    <div class ="mainDiv">
    <form id="form1" runat="server">
       <div>
               <input type="button" class ="smallbutton" value ="新增项目" onclick ="jump()"/>
              <%-- <label class="lbZS" title ="" >(注:输入项目名称、项目地点或建设单位可快速查询到相应的项目)</label>--%>
        </div>
        <div style ="height:auto;" class="GV" runat ="server" align="center" >
                <asp:GridView ID="GridView" runat="server"  AutoGenerateColumns="False"  
                    DataKeyNames="XMID" CssClass="biaoge"
          OnRowDataBound="GridView_RowDataBound" OnRowCreated="GridView_RowCreated" 
                    OnRowCommand="GridView_RowCommand" >

在浏览器里运行后,为什么GridView不显示呢?

pengjw的主页 pengjw | 初学一级 | 园豆:3
提问于:2013-03-12 12:57
< >
分享
最佳答案
0

是不是Gridview没数据,没数据的时候不显示的

收获园豆:2
九九哥 | 初学一级 |园豆:182 | 2013-03-12 13:59

嗯,我还没绑定数据源,我知道了,我先绑定数据源试试。不对啊,至少Gridview表头该显示出来呢?

pengjw | 园豆:3 (初学一级) | 2013-03-12 14:01
其他回答(2)
0

你看看biaoge 里有没有定义display:none

收获园豆:1
Mike Mao | 园豆:162 (初学一级) | 2013-03-12 13:12

样式文件里biaoge没定义display,

.biaoge
{
    padding :0px;
    font-size :13px;
    font-weight :normal ;
    color :#000000;
    line-height :25px;
    font-family :Arial, Helvetica, Sans-Serif ;
    border-collapse :collapse ; 
    }

上面就是表格的所有定义,

支持(0) 反对(0) pengjw | 园豆:3 (初学一级) | 2013-03-12 13:34
0

Gridview 默认情况下,没有数据源是不会显示的。

收获园豆:2
geass.. | 园豆:1821 (小虾三级) | 2013-03-12 16:12

嗯,我现在想在后台写数据绑定的方法,但是不能获取GridView的ID

private void BindData()
        {
            DataSet ds = null;
            int recordCount = 0, start = 0, end = 0;
            if (ds.Tables[0].Rows.Count == 0)
            {
                DataRow dr = ds.Tables[0].NewRow();
                ds.Tables[0].Rows.Add(dr);
                this.GridView.DataSource = ds.Tables[0];
            }

        }

上面的代码老是在this.GridView那里报错,说没有定义GridView,或者么有引用程序集,咋办?

支持(0) 反对(0) pengjw | 园豆:3 (初学一级) | 2013-03-12 16:14

@pengjw: 

DataSet ds = null;
if (ds.Tables[0].Rows.Count == 0) 这里不会报错?
支持(0) 反对(0) geass.. | 园豆:1821 (小虾三级) | 2013-03-12 16:43

@geass..: 那里没有报错,只在this.GridVIew那报错

支持(0) 反对(0) pengjw | 园豆:3 (初学一级) | 2013-03-12 16:51

@pengjw: 可能是因为VS的问题,或者是你的 ASPX 页面的 codebehind 的指向类 跟 ASPX.CS的类名不一样。重启下VS试下。但 if (ds.Tables[0].Rows.Count == 0) 这里一定会运行时的错误。

支持(0) 反对(0) geass.. | 园豆:1821 (小虾三级) | 2013-03-12 17:07

@geass..: 嗯,我试试

支持(0) 反对(0) pengjw | 园豆:3 (初学一级) | 2013-03-12 17:09

@pengjw: 

把ID名称修改下吧不要和GridView类冲突了,GridView控件数据源没有数据的时候整个表格都不显示的包括表头,貌似有属性可以设置的吧,找找看...

支持(0) 反对(0) 三桂 | 园豆:3565 (老鸟四级) | 2013-03-13 11:42
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册