网格视图可见性问题 [英] Grid view Visibilty problem

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

问题描述

我具有以下用于网格视图的代码,并使用从Web服务检索的数据集将其绑定


I have the following code for grid view and bind it using a data set which i retrieve from webservice


<asp:GridView ID="grdViewWarnings" runat="server" AutoGenerateColumns ="False" BorderWidth="1px" BackColor="#DEBA84" 
             CellPadding="3" CellSpacing="2" BorderStyle="None" 
             BorderColor="#DEBA84" Width="800px">
             <footerstyle forecolor="#8C4510">
              BackColor="#F7DFB5"></footerstyle>
            <pagerstyle forecolor="#8C4510">
              HorizontalAlign="left"></pagerstyle>
            <HeaderStyle ForeColor="Black" Font-Bold="True" HorizontalAlign ="Left"
              BackColor="DarkGray"></HeaderStyle>
             <columns>
            <asp:BoundField DataField="Warnings" HeaderText="Warnings" /> 
            </columns>





grdViewWarnings.DataSource = dsDrugInfo.Tables["Warnings"];
grdViewWarnings.DataBind();





我的问题是如果要绑定的表中没有行,则不会对grdViewWarnings进行布局.

我希望即使没有行也要显示网格视图的标题.

请帮助我.





My problem is if there is no rows in the table I am binding,The grdViewWarnings is not being dislayed.

I want the header of the Grid View to be displayed even if there are no rows.

Plz help me.

推荐答案

<asp:gridview id="grdViewWarnings" runat="server" autogeneratecolumns="False" borderwidth="1px" backcolor="#DEBA84" xmlns:asp="#unknown"EmptyDataText="Warnings"
             CellPadding="3" CellSpacing="2" BorderStyle="None" 
             BorderColor="#DEBA84" Width="800px">
             <footerstyle forecolor="#8C4510">
              BackColor="#F7DFB5"></footerstyle>
            <pagerstyle forecolor="#8C4510">
              HorizontalAlign="left"></pagerstyle>
            <headerstyle forecolor="Black" font-bold="True" horizontalalign="Left">
              BackColor="DarkGray"></headerstyle>
             <columns>
            <asp:boundfield datafield="Warnings" headertext="Warnings" /> 
            </columns>



使用EmptyDataText属性,这可能会帮助您



Use EmptyDataText property,this might help you


尝试此

try this

<asp:GridView ID="GridView1" DataKeyNames="Id" ShowHeader="true" EmptyDataText="No Records" runat="server">


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

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