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

GridView not displaying on page after postback

Hi,

I am trying to build a simple web page that displays records returned from
an MS Access db when the user enters search criteria in a text box on the
same page. My page comprises of a label, textbox and a button, together with
an unbound GridView
and an AccessDataSource control.

In the Page_Load event, I have the following code:

if (!IsPostBack)
{
GridView1.Visible = false;
}
else
{
// Get search term entered by user.
string searchTerm = textSearch.Text;

// Query the database for matching records.
AccessDataSource1.SelectCommand = string.Format("SELECT *
FROM MyTable WHERE Column1 LIKE '%{0}%'", searchTerm);
GridView1.DataSource =
AccessDataSource1.Select(DataSourceSelectArguments .Empty);
GridView1.DataBind();
GridView1.Visible = true;

My problem is that when I step through the code, I can verify that the
DataView returned by the AccessDataSource.Select() method contains data, yet
the GridView does not show on the page.

What am I doing wrong?

Jazza
Oct 25 '07 #1
3 2311
Use DatSoureId property of GridView
Oct 25 '07 #2
I tried your suggestion, but now it throws an exception "Both DataSource and
DataSourceID are defined in Gridview1"

"donet programmer" wrote:
Use DatSoureId property of GridView
Oct 26 '07 #3
Ignore post, I found the answer myself: GridView1.AutoGenerateColumns = true;

"donet programmer" wrote:
Use DatSoureId property of GridView
Oct 26 '07 #4

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

Similar topics

2
by: Dabbler | last post by:
What's the best way to return to GridView after editing a detail record in a FormView so the GridView shows the page with the edited record on it? I'm using GridView with standard...
0
by: steve.craver | last post by:
I am working with a multi-field search form which, when the form is submitted, queries a database and returns the results into a paginated GridView object. The site is being developed with master...
12
by: Cindy Lee | last post by:
When I do a sorta on 1 table, then the other table goes back to the original order. What can I set so, it keeps the order of the other current gridview's order. I set all the gridview values...
1
by: Larry Bud | last post by:
What's the best way to only show a gridview on a postback? The reason is that I have a simple search page with a couple of fields, and I want those fields to be chosen before displaying every row...
1
by: Ganesh | last post by:
Hi There, I've a GridView contains hyperlink in each row. If user click that link it will open another detail page with all information. After seeing the details user can go back to search...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.