在asp.net中始终显示gridview标头 [英] Show always gridview header in asp.net
本文介绍了在asp.net中始终显示gridview标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个GridView,并且我也想在gridview数据源也为null时显示gridview标头,应该遵循的方式是什么?
谢谢.
I have a GridView and I want to show the gridview header when gridview data source is null too.What will be the way that should I follow?
Thank you.
推荐答案
您好,这里考虑dtCustomer是包含您的数据的DataTable.
代码在下面
Hi, here consider dtCustomer is DataTable which contains your Data.
code is below
if (dtCustomer != null)
{
if (dtCustomer.Rows.Count > 0)
{
GridView1.DataSource = dtCustomer;
GridView1.DataBind();
}
else
{
dtCustomer.Rows.Add(dtCustomer.NewRow());
GridView1.DataSource = dtCustomer;
GridView1.DataBind();
int TotalColumns = GridView1.Rows[0].Cells.Count;
GridView1.Rows[0].Cells.Clear();
GridView1.Rows[0].Cells.Add(new TableCell());
GridView1.Rows[0].Cells[0].ColumnSpan = TotalColumns;
GridView1.Rows[0].Cells[0].Text = "No Data";
}
}
else
{
//Here if you want, you can call the inner else condition code here
}
这篇关于在asp.net中始终显示gridview标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文