473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SqlDataSource1 empty?

I have a gridview with a sqldatasource going to a sql server.
I have a lot of conditional-displayed placeholders
how do i tell if the gridview comes up with no records before the page
loads, so I don't get an error?
Jan 30 '07 #1
2 1075
Hi Mr. Sweety,

1. If Page is displayed by the first time (IsPostBack == false)
You cannot access this information on page load because SqlDataSource
retrieves its data on PreRender, but you can see if there are any records
handling gridview's DataBound event:

protected void GridView1_DataBound(object sender, EventArgs e)
{
GridView gridView = (GridView)sender;
bool hasResults = gridView.Rows.Count;
}

2. Page is posted back (IsPostBack == false) and viewstate is enabled:
(simplifying) data is not bound, items are restored from viewstate in
page_init (which occurs before Page_load) so you may test for emptiness.

In addition to that, there are many events you could handle in SqlDataSource
: i.e. Selected, Selecting etc.

Hope this helps

Milosz
"Mr. SweatyFinger" wrote:
I have a gridview with a sqldatasource going to a sql server.
I have a lot of conditional-displayed placeholders
how do i tell if the gridview comes up with no records before the page
loads, so I don't get an error?
Jan 30 '07 #2
you are a good helper .

Jan 31 '07 #3

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

Similar topics

4
by: Cyrus D. | last post by:
Hi guys, What's the best way to test for an empty form value ? I am doing it like this now: $test = $_POST; if(strlen($test) < 1) // it is empty ! Maybe I can just go:
13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
12
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested....
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as...
11
by: Dan Bass | last post by:
which one do you use and why? MyString == null || MyString == "" vs MyString == null || MyString.Length == 0
2
by: Bob Stearns | last post by:
I thought that the given expression was always TRUE if "not_there" wasn't among the keys (or subscripts if you will) of $_SESSION. Below find a dump of $_SESSION, a small snippet of code and the...
14
by: cj | last post by:
What is string.empty used for? I can't say: if string.empty then I have to use: if string = "" then which is ok, I just want to know what .empty is for.
3
by: nitinp | last post by:
I want to bind GridView with sqlDataSource like following sqlDataSource1.SelectCommand = "GET_TRACKING_INFO"; sqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure; ...
0
by: gigi.lagria | last post by:
I am getting the following error only on pages that contain a SqlDateSource (all other pages pull data fine). Access to the ADO.net Managed Provider 'SqlClientFactory' was denied in the data...
26
by: anonieko | last post by:
In the past I always used "" everywhere for empty string in my code without a problem. Now, do you think I should use String.Empty instead of "" (at all times) ? Let me know your thoughts.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
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,...
0
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
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,...

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.