Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > datagrid with no records - showing a line

Reply
Thread Tools

datagrid with no records - showing a line

 
 
Tony Farrell
Guest
Posts: n/a
 
      02-25-2004
Hi everyone,

Using asp.net and a datagrid -

When there are no records returned from
the query - is there a way to add/insert
a line into the grid stating there is/are
no records to display???

thanks
tony
 
Reply With Quote
 
 
 
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      02-25-2004
I've found the easiest way is after binding, check to see if there are no
records returned. If not, hide the DataGrid and show a Label that says,
"No records," or whatnot. If there are records, then do the opposite.

That is, you might have something like:

myDataGrid.DataSource = ...
myDataGrid.DataBind()

If myDataGrid.Items.Count = 0 then
'There are no records
myDataGrid.Visible = False
someLabelWithAMessage.Visible = True
Else
myDataGrid.Visible = True
someLabelWithAMessage.Visible = False
End If


Happy Programming!

--

Scott Mitchell
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!



"Tony Farrell" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi everyone,
>
> Using asp.net and a datagrid -
>
> When there are no records returned from
> the query - is there a way to add/insert
> a line into the grid stating there is/are
> no records to display???
>
> thanks
> tony



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sh Crypto isakmp sa is showing Active but Tunnel is showing line protocol down. urvin Cisco 0 04-15-2008 08:17 AM
Datagrid not showing records on production server syedrafey@gmail.com ASP .Net 1 04-10-2006 08:18 AM
ASP 1.1: DataGrid - Showing/Not Showing Buttons Ray Booysen ASP .Net 2 03-28-2006 02:49 PM
How to prevent a checkbox from showing up in a datagrid with no records? Burak ASP .Net Datagrid Control 1 05-18-2004 06:01 PM
match muliple header records to associated detail records Luke Airig XML 0 12-31-2003 12:06 AM



Advertisments