Gridview display for an empty dataset

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 45
Reputation: Sarah Lee is an unknown quantity at this point 
Solved Threads: 0
Sarah Lee Sarah Lee is offline Offline
Light Poster

Gridview display for an empty dataset

 
0
  #1
Feb 9th, 2007
Hi Everybody

How can i display in the gridview.
"there is no data for this request" if the binded dataset is empty?

Can anyone give some ideas?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 130
Reputation: sedgey is on a distinguished road 
Solved Threads: 8
sedgey's Avatar
sedgey sedgey is offline Offline
Junior Poster

Re: Gridview display for an empty dataset

 
0
  #2
Feb 9th, 2007
why not check whether the DataSet has any rows in code before binding then show/hide a label with that text?
David Ridgway: so little daylight, too much caffeine
MCSD MCAD MCSE
http://web2asp.net
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 130
Reputation: sedgey is on a distinguished road 
Solved Threads: 8
sedgey's Avatar
sedgey sedgey is offline Offline
Junior Poster

Re: Gridview display for an empty dataset

 
0
  #3
Feb 9th, 2007
alternatively if it must appear in the grid view, why not build a data table with one column called result and add a row who's value is your text, then bind it to your grid view
David Ridgway: so little daylight, too much caffeine
MCSD MCAD MCSE
http://web2asp.net
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 45
Reputation: Sarah Lee is an unknown quantity at this point 
Solved Threads: 0
Sarah Lee Sarah Lee is offline Offline
Light Poster

Re: Gridview display for an empty dataset

 
0
  #4
Feb 12th, 2007
Thanks
First one seems to be more easy
I will try for that
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 79
Reputation: nikkiH is an unknown quantity at this point 
Solved Threads: 4
nikkiH's Avatar
nikkiH nikkiH is offline Offline
Junior Poster in Training

Re: Gridview display for an empty dataset

 
1
  #5
Feb 12th, 2007
GridView supports EmptyDataRowStyle

http://msdn2.microsoft.com/en-us/lib...arowstyle.aspx
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 130
Reputation: sedgey is on a distinguished road 
Solved Threads: 8
sedgey's Avatar
sedgey sedgey is offline Offline
Junior Poster

Re: Gridview display for an empty dataset

 
0
  #6
Feb 12th, 2007
spot on nikkiH
David Ridgway: so little daylight, too much caffeine
MCSD MCAD MCSE
http://web2asp.net
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 17
Reputation: znetweb is an unknown quantity at this point 
Solved Threads: 0
znetweb znetweb is offline Offline
Newbie Poster

Re: Gridview display for an empty dataset

 
0
  #7
May 25th, 2009
If there is No Data in Gridview and we want to show a message that “No data available”.
We can do this by using the following tag in gridview.

  1. <EmptyDataTemplate>
  2.  
  3. No Data Available
  4.  
  5. </EmptyDataTemplate>
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 220
Reputation: mail2saion is an unknown quantity at this point 
Solved Threads: 33
mail2saion's Avatar
mail2saion mail2saion is offline Offline
Posting Whiz in Training

Re: Gridview display for an empty dataset

 
0
  #8
May 26th, 2009
JUST ADD THE EmptyDataText PROPERTY IN THE FOLLOWING WAY:
  1. <asp:GridView runat="server" ID="gvCaseDetail" Width="100%"
  2. EmptyDataText="there is no data for this request"
  3. ......................................

YOU CAN ALSO RENDER HTMEL TEXT LIKE:
  1. <asp:GridView runat="server" ID="gvCaseDetail" Width="100%"
  2. EmptyDataText="<table cellspacing=1 cellpadding=4 rules=rows border=0 style=color:Black;font-family:Tahoma;font-size:1em;width:730px;border-collapse:collapse;><tr style=color:Black;background-color:#00BFFF;font-weight:bold;><th scope=col>Case ID</th><th align=center scope=col>Subject</th><th align=center scope=col>Status</th><th align=center scope=col>Date</th><th align=center scope=col>Action</th></tr></table>"
  3. ..............................

ONE THING YOU HAVE TO KEEP IN MIND THAT IF YOU DIDN'T BIND ANY DATASOURCE YOU WILL GET BLANK.
MARK AS SOLVED if its help you.

REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,634
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 472
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: Gridview display for an empty dataset

 
0
  #9
May 26th, 2009
Dear,

zneweb and mail2saion have solved your problem.

  1. <asp:GridView ID="GridView1" runat="server">
  2. <EmptyDataTemplate>
  3. There is no data.
  4. </EmptyDataTemplate>
  5. </asp:GridView>
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 1
Reputation: argisoft is an unknown quantity at this point 
Solved Threads: 0
argisoft argisoft is offline Offline
Newbie Poster

Re: Gridview display for an empty dataset

 
0
  #10
May 26th, 2009
try with this. My english is poor ok?

  1. Public Sub CheckEmptyGrid(ByVal grid As WebControls.GridView)
  2.  
  3. If grid.Rows.Count = 0 And Not grid.DataSource Is Nothing Then
  4. Dim dt As Object = Nothing
  5. If grid.DataSource.GetType Is GetType(Data.DataSet) Then
  6. dt = New System.Data.DataSet
  7. dt = CType(grid.DataSource, System.Data.DataSet).Tables(0).Clone()
  8. ElseIf grid.DataSource.GetType Is GetType(Data.DataTable) Then
  9. dt = New System.Data.DataTable
  10. dt = CType(grid.DataSource, System.Data.DataTable).Clone()
  11. ElseIf grid.DataSource.GetType Is GetType(Data.DataView) Then
  12. dt = New System.Data.DataView
  13. dt = CType(grid.DataSource, System.Data.DataView).Table.Clone
  14. End If
  15. dt.Rows.Add(dt.NewRow())
  16. grid.DataSource = dt
  17. grid.DataBind()
  18. grid.Rows(0).Visible = False
  19. grid.Rows(0).Controls.Clear()
  20. End If
  21. End Sub

and the call

  1. CheckEmptyGrid(Grid)

With this the headers appers ok
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC