473,461 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Default text for blank or empty datalist

I have looked everywhere and honestly can't believe I am the only one
trying to figure this out. Maybe I am searching under the wrong
keywords.

I have a datalist. It is bound to an array, but could be bound to
anything - dataset, whatever. If, when bound, there are no values,
all that shows on the datalist is the header and the footer, with no
space in between. I want to display a default message - something
like "There are no values"

Any ideas?
Nov 18 '05 #1
1 5986
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
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

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


"j_ruez" <j_****@yahoo.com> wrote in message
news:17**************************@posting.google.c om...
I have looked everywhere and honestly can't believe I am the only one
trying to figure this out. Maybe I am searching under the wrong
keywords.

I have a datalist. It is bound to an array, but could be bound to
anything - dataset, whatever. If, when bound, there are no values,
all that shows on the datalist is the header and the footer, with no
space in between. I want to display a default message - something
like "There are no values"

Any ideas?

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ruben | last post by:
Hello. I am trying to read a small text file using the readline statement. I can only read the first 2 records from the file. It stops at the blank lines or at lines with only spaces. I have a...
2
by: Gary | last post by:
Hi, I am a Chinese student, I have a problem with the following code //The follwing code in StaticSearch.h: // template <class Type> class dataList; // template <class Type> class Node ...
2
by: Todd | last post by:
I am somewhat new to ASP.NET and I am probably overlooking some basic rule that's causing my error. Anyways, here's the scoop: I am using a DataReader to access a SQL stored procedure. I want...
0
by: Anonieko Ramos | last post by:
Answer. Use IHttpHandler. thanks Ro ry for coming up with this code. It processes css file to add variables. neat idea using System; using System.IO; using System.Text; using...
11
by: Michael Groeger | last post by:
Hi, is it possible to leave a DropDownList's selection empty? Our application requires for some ddl's that they are kept blank w/o an initial value so that we can add a RequiredFieldValidator to...
2
by: Olveres | last post by:
Hi, I have managed to work out how to add new lines into a calculated text box. However in this text box some of the outcome fields are empty however when previewing the report it includes the...
3
by: RipperT | last post by:
Hello, I am using VB2005. I would like to check a textbox to see if it is blank using a Try Catch block. I assumed an easy way to do that would be to perform some action on the string that can't...
1
by: Steve Hershoff | last post by:
I'm using VS 2003, and need to extract the text from an asp label in my code-behind file. The label is part of a DataList's ItemTemplate. I've noticed that in my ascx file (we're using User...
1
by: goldpython | last post by:
I'm working in C#, .NET framework 2.0. I'm writing a text editor and wanted a finer degree of control over the window that a normal edit box will allow, and so decided to build the display...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.