Datagrid empty data hides header

  • Thread starter Roby Eisenbraun Martins
  • Start date
R

Roby Eisenbraun Martins

Hi,

I have a gridview (NET 2005) and when it hasn't got values it shows a
nice "Not found" text message. But unfortunately all the gridview lay-out
hides( header, ... ).
Is there a property to keep the gridview visible even if the data is
empty?

Thank you,
Roby Eisenbraun Martins
 
P

Phillip Williams

Hi Roby,

I found in both ASP.NET 1.1 and 2.0 that you cannot do that except by having
another table (with its visible attribute set to false) on the page then upon
databinding you would set visible = true when the datasource is null, e.g.

protected void GridView1_DataBinding(boject sender, EventArgs e)
{
GridView gv= (GridView)sender;
DataView dv = (DataView)gv.DataSource;
//if you are using a Business Logic Layer then replace the prevous line with
//equivalent type casting
MyEmptyTable.visible=true; //this is the table that you left to display
if there were no data

}
 
P

Phillip Williams

I missed the line that checks for the dataview is null, e.g.

if (dv == null) {
MyEmptyTable.Visible=true;
GridView1.Visible = false;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top