Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to show GridView bound to empty data source? (2.0)

Reply
Thread Tools

How to show GridView bound to empty data source? (2.0)

 
 
Tomasz Jastrzebski
Guest
Posts: n/a
 
      11-30-2006
Helo All,

The problem: GridView control does not render at all (header/footer) when
the data source is empty.
I have seen a similar question posted already, but I just can not believe
there is no simple solution.
I do not believe ASP.Net team took this, sort of, innovative approach and
left no way out.
Could anybody advise?

Thank you,
Tomasz


 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      11-30-2006
"Tomasz Jastrzebski" <> wrote in message
news:%...

> Could anybody advise?


1) Launch your internet browser (e.g. IE, FireFox, Netcape, Opera etc)

2) Navigate to http://www.google.com

3) Enter the text below in the box:

GridView DataSource empty

4) Hit the button


 
Reply With Quote
 
 
 
 
Tomasz Jastrzebski
Guest
Posts: n/a
 
      11-30-2006
Yeah, I think I have forgotten to to emphasize the word SIMPLE.
T


"Mark Rae" <> wrote in message
news:...
> "Tomasz Jastrzebski" <> wrote in message
> news:%...
>
>> Could anybody advise?

>
> 1) Launch your internet browser (e.g. IE, FireFox, Netcape, Opera etc)
>
> 2) Navigate to http://www.google.com
>
> 3) Enter the text below in the box:
>
> GridView DataSource empty
>
> 4) Hit the button
>



 
Reply With Quote
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      11-30-2006
Perhaps the emptydatatext property of gridview would be simple enough
http://msdn2.microsoft.com/en-us/lib...ydatatext.aspx

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog


"Tomasz Jastrzebski" <> wrote in message
news:...
> Yeah, I think I have forgotten to to emphasize the word SIMPLE.
> T
>
>
> "Mark Rae" <> wrote in message
> news:...
>> "Tomasz Jastrzebski" <> wrote in message
>> news:%...
>>
>>> Could anybody advise?

>>
>> 1) Launch your internet browser (e.g. IE, FireFox, Netcape, Opera etc)
>>
>> 2) Navigate to http://www.google.com
>>
>> 3) Enter the text below in the box:
>>
>> GridView DataSource empty
>>
>> 4) Hit the button
>>

>
>



 
Reply With Quote
 
Tomasz Jastrzebski
Guest
Posts: n/a
 
      11-30-2006
Simple - yes, helpful - I do not know. Setting this property does not seem
to cause header/footer to render when data source is empty. Am I missing
something?

Thanks,
Tomasz

"John Timney (MVP)" <> wrote in message
news:. uk...
> Perhaps the emptydatatext property of gridview would be simple enough
> http://msdn2.microsoft.com/en-us/lib...ydatatext.aspx
>
> --
> Regards
>
> John Timney (MVP)
> VISIT MY WEBSITE:
> http://www.johntimney.com
> http://www.johntimney.com/blog
>
>
> "Tomasz Jastrzebski" <> wrote in message
> news:...
>> Yeah, I think I have forgotten to to emphasize the word SIMPLE.
>> T
>>
>>
>> "Mark Rae" <> wrote in message
>> news:...
>>> "Tomasz Jastrzebski" <> wrote in message
>>> news:%...
>>>
>>>> Could anybody advise?
>>>
>>> 1) Launch your internet browser (e.g. IE, FireFox, Netcape, Opera etc)
>>>
>>> 2) Navigate to http://www.google.com
>>>
>>> 3) Enter the text below in the box:
>>>
>>> GridView DataSource empty
>>>
>>> 4) Hit the button
>>>

>>
>>

>
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      12-01-2006
"John Timney (MVP)" <> wrote in message
news:. uk...

> Perhaps the emptydatatext property of gridview would be simple enough


That's certainly the way I do it...


 
Reply With Quote
 
AG
Guest
Posts: n/a
 
      12-01-2006
Apparently, MS doesn't consider this an issue and does not intend to change
it.
I submitted it to feedback and this is the result.
http://connect.microsoft.com/VisualS...dbackID=228384

While I haven't used it in production as yet, I am currently building a site
using the following, with a few tweaks.
http://www.codeproject.com/useritems...nsert_line.asp
If you want to be able to insert data, it works fine, except for one typo I
found.
If you just want to display header and footer without the insert, I think
you can easily modify it to do that.

The line:
public event GridViewUpdatedEventHandler RowInserting {
shoule be:
public event GridViewUpdateEventHandler RowInserting {

I also made a slight change to better handle utilizing template columns for
the command columns.

--

AG
Email: discuss at adhdata dot com



"Tomasz Jastrzebski" <> wrote in message
news:%...
> Helo All,
>
> The problem: GridView control does not render at all (header/footer) when
> the data source is empty.
> I have seen a similar question posted already, but I just can not believe
> there is no simple solution.
> I do not believe ASP.Net team took this, sort of, innovative approach and
> left no way out.
> Could anybody advise?
>
> Thank you,
> Tomasz
>



 
Reply With Quote
 
thomas
Guest
Posts: n/a
 
      12-01-2006
Well, I should have guessed. I think it's my frustration. So good it's
almost Friday.
T

"Mark Rae" <> wrote in message
news:%...
> "John Timney (MVP)" <> wrote in message
> news:. uk...
>
>> Perhaps the emptydatatext property of gridview would be simple enough

>
> That's certainly the way I do it...
>



 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      12-01-2006
Hi Tomasz,

You could use GridView's EmptyDataTemplate to display a message to user
that the GridView doesn't have any data available:

<EmptyDataTemplate>
There is no data.
</EmptyDataTemplate>


However, it will not show the header or footer. As a workaround, you could
use following class:

#10,000 Monkeys - Harnessing The Power of Typing Monkeys : Displaying
GridView When No Data Exists
http://blogs.claritycon.com/blogs/ke...02/28/247.aspx


You could use this class instead of GridView where is needed; or use
following config to automatically replace all GridView with EmptyGridView
without changing your existing WebForms:

<system.web>
<pages>
<tagMapping>
<!-- assume you added EmptyGridView to App_Code folder within namespace
"myns" -->
<add tagType="System.Web.UI.WebControls.GridView"
mappedTagType="myns.EmptyGridView,App_Code"/>
</tagMapping>
</pages>
</system.web>


Sincerely,
Walter Wang (, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      12-01-2006
If its not appropriate, you could probably just check the recordcount of the
datatable before you bind, and if its zero bind to a manually created
datatable containing a single record of spaces. That will render your
header and footer.

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog


"thomas" <> wrote in message
news:...
> Well, I should have guessed. I think it's my frustration. So good it's
> almost Friday.
> T
>
> "Mark Rae" <> wrote in message
> news:%...
>> "John Timney (MVP)" <> wrote in message
>> news:. uk...
>>
>>> Perhaps the emptydatatext property of gridview would be simple enough

>>
>> That's certainly the way I do it...
>>

>
>



 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Lower bound & Upper bound sunil panda Java 9 10-07-2008 08:32 PM
Data-bound DataGridView creates bogus empty rows JustinD30324@gmail.com ASP .Net 1 07-06-2008 06:06 AM
How to represent the data in a not bound control via bound control Mario Krsnic ASP .Net 0 06-23-2006 07:38 AM
Getting lower-bound and upper-bound of strings input Rhiner Dan C++ 1 03-27-2005 02:03 AM



Advertisments