如何检查Gridview是否为空 [英] How to check Gridview is empty
问题描述
我在gridview之外有一个下拉列表..dropdownlist包含用户,管理员和禁用成员三项内容.当我选择用户时,它显示gridview中的所有用户;当我选择管理员时,它显示所有管理员成员. >
我想检查数据库中没有管理员时的情况.并且我从下拉列表中选择.它显示一些消息..
如何检查我的gridview为空意味着没有与我的查询相关的数据,请从下拉列表中选择.
谢谢..
I have dropdownlist outside of gridview ..dropdownlist contain three things users,admin and disabled member..when i select user it shows all users in gridview and when i select admin..its shows all admin member..
i want to check the condition when there is no admin in database..and i select from dropdownlist..its show some message ..
how can i check my gridview is empty means it has no data related to my query select from dropdown list.
Thank you..
推荐答案
尝试一下
try this
<asp:gridview id="GvBOLList" runat="server" autogeneratecolumns="False" xmlns:asp="#unknown">
CellPadding="4" DataKeyNames="No" PageSize="99">
<selectedrowstyle backcolor="Gray" font-names="Tahoma" font-size="10pt" />
<columns>
<asp:boundfield datafield="Ship" headertext="Ship" />
</columns>
<emptydatarowstyle backcolor="#F7F6F3" />
<emptydatatemplate>
<table>
<tr>
<td>
<asp:image id="Image1" imageurl="~/images/warning.jpg" runat="server" imagealign="Middle">
Width="14px" Height="14px" />
No Records Found!!!
</asp:image></td>
</tr>
</table>
</emptydatatemplate>
</asp:gridview>
在空数据模板中,您可以使用任何图像或将文本显示为空.
in empty data template you can use any image or display text as empty.
设置 ^ ]-GridView对象的属性.
Set the EmptyDataText[^]-property of the GridView object.
if(gridview.rows.count == 0)
{
label.text =网格视图没有数据";
}
我发现解决方案..它非常简单..thanx
if(gridview.rows.count==0)
{
label.text="grid view have no data";
}
i found the solutions..its very simple..thanx
这篇关于如何检查Gridview是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!