.NETGURU
Display DataGrid when no data
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngcontrolsvb' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Anders.Vikstrom@banqit.com
Hi,

Does anybody know if it is possible to have a DataGrid display itself
(atleast a header) although it does not contain any data? I suppose I =
have
to write my own control, have it inherit the DataGrid, and do some =
trick
when rendering, right?

Thanks in advance,

Anders Vikstr=F6m
SW Engineering, BANQIT AB
http://www.banqit.com
mailto:Click here to reveal e-mail address
Phone: +46 8 7594737

Reply to this message...
 
    
Susan Warren
It's easier than that -- no need to create a derived control. You just =
need to bind the grid. If the datasource exists but contains no =
items/rows and ShowHeader=3Dtrue (that's the default), you'll see just =
the header. I also usually add a "no records found" item to the grid so =
that it's not just a header by hooking the grid's OnItemCreated event =
and showing this message in the footer:

// handles OnItemCreated for my DataGrid

void CheckGridEmpty(object sender, DataGridItemEventArgs e) {

// buff up the presentation a bit if the grid is empty
if (e.Item.ItemType =3D=3D ListItemType.Footer) {
=20
// add a message in the footer if there are no items
DataGrid dg =3D (DataGrid)sender;
int count =3D dg.Items.Count;
if (count =3D=3D 0) {
dg.ShowFooter =3D true;
e.Item.Cells[0].Text =3D "No items found.";
}
else {=20
dg.ShowFooter =3D false;
}
}
}

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]=20
Sent: Wednesday, October 17, 2001 2:42 AM
To: aspngcontrolsvb
Subject: [aspngcontrolsvb] Display DataGrid when no data

Hi,

Does anybody know if it is possible to have a DataGrid display itself
(atleast a header) although it does not contain any data? I suppose I =
have
to write my own control, have it inherit the DataGrid, and do some trick
when rendering, right?

Thanks in advance,

Anders Vikstr=F6m
SW Engineering, BANQIT AB
http://www.banqit.com
mailto:Click here to reveal e-mail address
Phone: +46 8 7594737

| [aspngcontrolsvb] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngcontrolsvb.asp =3D JOIN/QUIT
| http://www.asplists.com/search =3D SEARCH Archives

Reply to this message...
 
    
Saurabh Nandu (VIP)
I guess what you want is a default behavior ... Even if you don't have
any data .. the datagrid is shown (my examples work without data ..)

Regards,
Saurabh Nandu
Web Master: http://www.MasterCSharp.com
Master C#, the easy way...

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]=20
Sent: Wednesday, October 17, 2001 3:12 PM
To: aspngcontrolsvb
Subject: [aspngcontrolsvb] Display DataGrid when no data

Hi,

Does anybody know if it is possible to have a DataGrid display itself
(atleast a header) although it does not contain any data? I suppose I
have
to write my own control, have it inherit the DataGrid, and do some trick
when rendering, right?

Thanks in advance,

Anders Vikstr=F6m
SW Engineering, BANQIT AB
http://www.banqit.com
mailto:Click here to reveal e-mail address
Phone: +46 8 7594737

Reply to this message...
 
 
System.Web.UI.WebControls.DataGrid
System.Web.UI.WebControls.DataGridItemEventArgs
System.Web.UI.WebControls.ListItemType
System.Windows.Forms.DataGrid




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification