473,396 Members | 1,996 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.

Databind for GridView

8
Hi,

I got a question when about the databinding for GridView. I am using the data source configuration wizard to bind a sqlsource1 from my database. However,
I need way to find if there are data return from my database, if yes, I will show the data, or, If no, I want to show a message says that "no record has been found". I am using a search buttom to trigger the databinding procedure.

here is part of my code:

protected void ButtonSearch_Click(object sender, EventArgs e)
{
if (GridView1.Rows.Count > 0)
{
Label1.Text = "3. Please select an address below";
}
else
{
Label1.Text = "No records! Please enter a valid site address.";
}

However, I noticed that the databind alway happens after the buttom click event, that means, the GridView1.Row.Count always return 0.

Please give me some suggest.
Thanks for your reply!
Aug 22 '07 #1
1 1192
nateraaaa
663 Expert 512MB
Hi,

I got a question when about the databinding for GridView. I am using the data source configuration wizard to bind a sqlsource1 from my database. However,
I need way to find if there are data return from my database, if yes, I will show the data, or, If no, I want to show a message says that "no record has been found". I am using a search buttom to trigger the databinding procedure.

here is part of my code:

protected void ButtonSearch_Click(object sender, EventArgs e)
{
if (GridView1.Rows.Count > 0)
{
Label1.Text = "3. Please select an address below";
}
else
{
Label1.Text = "No records! Please enter a valid site address.";
}

However, I noticed that the databind alway happens after the buttom click event, that means, the GridView1.Row.Count always return 0.

Please give me some suggest.
Thanks for your reply!
You should call a proc that will return the data for the search. Use that as your datasource then bind the data to the gridview. After that is where you should check the count of the gridview.

Nathan
Aug 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: jslaybaugh | last post by:
I am trying to bind to a GridView or DetailsView after a callback using the ClientCallback Manager in the new .NET 2.0 framework. See below for the HTML followed by the VB code: <html...
0
by: sreejith.ram | last post by:
I did google & search in this group , but couldnt find any thing related to this. This is my first attempt to connect GridView to a Oracle database via SqlDataSource. I am receving error message...
3
by: K B | last post by:
Hi again, I've narrowed down my problem and am hoping to get some help to get the final answer. Gridview with dynamic child controls loads gv1.Databind calls RowDataBound event fine On the...
3
by: Mark Leistner | last post by:
I am having problems getting a gridview to bind to custom objects under any non-full trust level. I created a test project to verify what I am seeing isn't a side effect of other code in my...
0
by: ack95 | last post by:
Simply question How can I DataBind() a DataViewManager to a GridView in ASP.NET? Question in Detail We have a DataSet with relational DataTables (total of 5). We are generating emails with...
1
by: Mark Olbert | last post by:
I have a GridView as a child control in a custom composite control which is stubornly refusing to databind at design time. I'm convinced I must be missing something about how the databinding process...
3
by: gihope | last post by:
Can anyone tell me why I am not allowed to bind a two or multi dimensional array to GridView and possibly suggest how they would deal with similar scenarios? The array is simply a two dimensional...
3
by: Dave | last post by:
I have an GridView on one page that will open a popup for the selected record. I've been told that there is a way that when the popup record is updated the GridView can be refreshed or Databind. ...
1
by: =?Utf-8?B?cmxt?= | last post by:
I have standard gridview in an updatePanel with an AJAX timer that refreshes the data every 5 seconds by calling the grids DataBind method in the tick event. This works great. However, I have a...
2
by: Andy B | last post by:
I don't know if this is even working or not but here is the problem. I have a gridview that I databound to a dictionary<string, stringcollection: Contract StockContract = new Contract();...
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
BarryA
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...
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
marktang
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,...
0
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...
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...
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.