| | |
Gridview display for an empty dataset
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
why not check whether the DataSet has any rows in code before binding then show/hide a label with that text?
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
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/
Bored? Visit http://www.kaelisspace.com/
•
•
Join Date: May 2008
Posts: 17
Reputation:
Solved Threads: 0
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.
We can do this by using the following tag in gridview.
ASP.NET Syntax (Toggle Plain Text)
<EmptyDataTemplate> No Data Available </EmptyDataTemplate>
JUST ADD THE EmptyDataText PROPERTY IN THE FOLLOWING WAY:
YOU CAN ALSO RENDER HTMEL TEXT LIKE:
ONE THING YOU HAVE TO KEEP IN MIND THAT IF YOU DIDN'T BIND ANY DATASOURCE YOU WILL GET BLANK.
ASP.NET Syntax (Toggle Plain Text)
<asp:GridView runat="server" ID="gvCaseDetail" Width="100%" EmptyDataText="there is no data for this request" ......................................
YOU CAN ALSO RENDER HTMEL TEXT LIKE:
ASP.NET Syntax (Toggle Plain Text)
<asp:GridView runat="server" ID="gvCaseDetail" Width="100%" 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>" ..............................
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
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
Dear,
zneweb and mail2saion have solved your problem.
zneweb and mail2saion have solved your problem.
ASP.NET Syntax (Toggle Plain Text)
<asp:GridView ID="GridView1" runat="server"> <EmptyDataTemplate> There is no data. </EmptyDataTemplate> </asp:GridView>
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: May 2009
Posts: 1
Reputation:
Solved Threads: 0
try with this. My english is poor ok?
and the call
With this the headers appers ok
ASP.NET Syntax (Toggle Plain Text)
Public Sub CheckEmptyGrid(ByVal grid As WebControls.GridView) If grid.Rows.Count = 0 And Not grid.DataSource Is Nothing Then Dim dt As Object = Nothing If grid.DataSource.GetType Is GetType(Data.DataSet) Then dt = New System.Data.DataSet dt = CType(grid.DataSource, System.Data.DataSet).Tables(0).Clone() ElseIf grid.DataSource.GetType Is GetType(Data.DataTable) Then dt = New System.Data.DataTable dt = CType(grid.DataSource, System.Data.DataTable).Clone() ElseIf grid.DataSource.GetType Is GetType(Data.DataView) Then dt = New System.Data.DataView dt = CType(grid.DataSource, System.Data.DataView).Table.Clone End If dt.Rows.Add(dt.NewRow()) grid.DataSource = dt grid.DataBind() grid.Rows(0).Visible = False grid.Rows(0).Controls.Clear() End If End Sub
and the call
ASP.NET Syntax (Toggle Plain Text)
CheckEmptyGrid(Grid)
With this the headers appers ok
![]() |
Similar Threads
- MultiLine TextBoxes in GridView edit mode (ASP.NET)
- GridView With More than one table (ASP.NET)
- Special formatting of a GridView... (ASP.NET)
- How can i retrieve data after i logod on..... (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Catching Dynamic Button Events
- Next Thread: Send email if no file exists
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn cac checkbox child class click compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownmenu dynamic edit embeddingactivexcontrol feedback findcontrol flash flv form forms gridview homeedition hosting iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings relationaldatabases rotatepage save search security serializesmo.table sessionvariables silverlight smartcard sql ssl suse textbox tracking treeview typeof unauthorized validatedate validation vb.net video virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webdevelopment wizard xml






