本文介绍了在没有可显示的数据时显示空gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i有一个gridview,它从database.i获取数据可以搜索和添加数据。但是当你搜索不存在的记录时,我会在一个标签中显示该消息以上d gridview.but我的问题是..我需要显示页眉和页脚(通过页脚插入)
请帮我...我需要尽快完成
谢谢
i have a gridview whose getting data from an database.i can do search and addition of data.but when u search for an record not present i ll display the message in a label present above d gridview.but my prob is..i need to display the header and footer(insertion through footers)
pls help me out...i need to do it soon
thanks
推荐答案
if (ds_login.Tables[0].Rows.Count == 0)
{
#region header with no record
ds_login.Tables[0].Rows.Add(ds_login.Tables[0].NewRow());
GridView1.DataSource = ds_login;
GridView1.DataBind();
int columncount = GridView1.Rows[0].Cells.Count;
GridView1.Rows[0].Cells.Clear();
GridView1.Rows[0].Cells.Add(new TableCell());
GridView1.Rows[0].Cells[0].ColumnSpan = columncount;
GridView1.Rows[0].Cells[0].Text = "No Records Found";
#endregion
}
else
{
GridView1.DataSource = ds_login;
GridView1.DataBind();
}
if (dt.Rows.Count > 0)
{
grid1.DataSource = dt;
grid1.DataBind();
}
else
{
dt.Rows.Add(dt.NewRow());
grid1.DataSource = dt;
grid1.DataBind();
int totalcolums = grid1.Rows[0].Cells.Count;
grid1.Rows[0].Cells.Clear();
grid1.Rows[0].Cells.Add(new TableCell());
grid1.Rows[0].Cells[0].ColumnSpan = totalcolums;
grid1.Rows[0].Cells[0].Text = "No Data Found";
}
这篇关于在没有可显示的数据时显示空gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!