What is a good way to check for a gridview or a datasource not having any rows?
If my gridview does not have any rows i want to display a message saying the
recordset is empty.
I'm doing it now by setting the message visible = true on page load
and set it to false on
if (e.Row.RowType == DataControlRowType.DataRow)
this.Label1.Visible = false;
Meaning it get s set to false on each row. I'd like a better way.
Thanks
KES
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes 4 29741
On Aug 29, 11:00 pm, WebBuilder451
<WebBuilder...@discussions.microsoft.comwrote:
What is a good way to check for a gridview or a datasource not having any rows?
If my gridview does not have any rows i want to display a message saying the
recordset is empty.
I'm doing it now by setting the message visible = true on page load
and set it to false on
if (e.Row.RowType == DataControlRowType.DataRow)
this.Label1.Visible = false;
Meaning it get s set to false on each row. I'd like a better way.
Thanks
KES
--
Do you know that there is the EmptyDataText Property that can be used
to show such message? http://msdn2.microsoft.com/en-us/lib...ydatatext.aspx
No i did not that is why i asked the question. Thank you for this answer it
is very much appreciated.
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes
"Alexey Smirnov" wrote:
On Aug 29, 11:00 pm, WebBuilder451
<WebBuilder...@discussions.microsoft.comwrote:
What is a good way to check for a gridview or a datasource not having any rows?
If my gridview does not have any rows i want to display a message saying the
recordset is empty.
I'm doing it now by setting the message visible = true on page load
and set it to false on
if (e.Row.RowType == DataControlRowType.DataRow)
this.Label1.Visible = false;
Meaning it get s set to false on each row. I'd like a better way.
Thanks
KES
--
Do you know that there is the EmptyDataText Property that can be used
to show such message? http://msdn2.microsoft.com/en-us/lib...ydatatext.aspx
On Aug 30, 2:48 pm, WebBuilder451
<WebBuilder...@discussions.microsoft.comwrote:
No i did not that is why i asked the question. Thank you for this answer it
is very much appreciated.
okay, and if you still want to use code-behind you can use Rows.Count
property
....
GridView1.DataBind();
if (GridView1.Rows.Count == 0) {
Label1.Text = "No records found";
Label1.Visible = true;
}
i was adding header rows on row data bound or row created and this was always
throwing the count off.
I did not see that property for empty text. Again This was an obvious, big
still a big help!
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes
"Alexey Smirnov" wrote:
On Aug 30, 2:48 pm, WebBuilder451
<WebBuilder...@discussions.microsoft.comwrote:
No i did not that is why i asked the question. Thank you for this answer it
is very much appreciated.
okay, and if you still want to use code-behind you can use Rows.Count
property
....
GridView1.DataBind();
if (GridView1.Rows.Count == 0) {
Label1.Text = "No records found";
Label1.Visible = true;
}
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul Telco |
last post by:
Hello,
I'm a new user designing a simple database to retrieve pre-prepared
docunents for printing.
I have five tables, a form to design the documents, a form to customise and
retrieve the...
|
by: S. van Beek |
last post by:
Dear reader
A record set can be empty because the condition in the query delivers no
records.
Is there a VBA code to check the status of a record set, record set empty
|
by: Oleg Ogurok |
last post by:
Hi all,
I want to use RegularExpressionValidator to enforce non-empty integer format
in a TextBox. However, the validator doesn't give the error when the textbox
is empty. For example, if...
|
by: Krish |
last post by:
Hello,
I have GridView and after binding data i can see cells empty only (empty row
is created), but i checked database there is data available. I just started
using GridView, trying to learn...
|
by: Mark Olbert |
last post by:
I ran into a situation this morning where the RowUpdating event of a GridView kept insisting there were no entries in either the
OldValues or NewValues dictionaries. The GridView is bound to a...
|
by: whisher |
last post by:
Hi.
I'm taking my first steps on regex I set up
this simple function to check if a form field is empty
or with only space.
var onlySpaceRegexp = /^\s*$/;
function isEmpty(val)
{
if...
|
by: Mr. SweatyFinger |
last post by:
how do i tell if i got back records (in code)
thanks
|
by: lphang |
last post by:
I am reading a simple text file that will contains three set of string values
as follow:
"1234567", "ABC123456", ""
I have my codes as follow trying to check for an empty string, with the input...
|
by: Knoxy |
last post by:
Hi guys,
I'm using a gridview to do some inline editing. The data binds okay,
its goes into edit mode and cancel okay. I'm using my own custom
commandName, "save", and it picks this up okay. Don't...
|
by: akshalika |
last post by:
I want regular expression which check for empty. pls help me.
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |