GridView not displaying on page after postback


G

Guest

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
 
Ad

Advertisements

G

Guest

I tried your suggestion, but now it throws an exception "Both DataSource and
DataSourceID are defined in Gridview1"
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top