By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,900 Members | 1,353 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,900 IT Pros & Developers. It's quick & easy.

Datagrid Display Not Working

P: n/a
Hello. For some reason, I am able to "connect" to the Northwind
database whenever I use the wizard; however, when I run the
application, my datagrid does not display. Here are the exact steps I
am taking to try to get this to run:

1)New Project -->ASP.NET Application
2) From the Server Explorer, drag the Northwind Employees table onto
the WebForm1.aspx design view. SqlConnection1 and SqlDataAdapter1 are
created.
3) From the Toolbox, drag the Datagrid control onto the WebForm1.aspx
web page.
4) Click on SqlDataAdapter1 box, select "Configure Data Adapter," and
fill out the settings for my server -- server name is the only one,
check "Use Windows Integrated Security," select the Northwind database,
and click on Test Connection. Succeeded. (Funny thing: On the
"Advanced" tab, none of the permissions are checked and I can't change
them.)
5)Click next and select "Use SQL Statements" for the rest of the
wizard.
6) Keep standard query generated out of the Employees table. ("SELECT
EmployeeID, LastName, FirstName, Title, TitleOfCourtesy, BirthDate,
HireDate, Address, City, Region, PostalCode, Country, HomePhone,
Extension, Photo, Notes, ReportsTo, PhotoPath FROM Employees")
7) Finish.
8)Click on Generate Dataset. It creates Dataset11.
9) Click on the Datagrid and use the dropdown in "Datasource" to select
Dataset11.

RUN.

The explorer page is blank, even though I can see the column names in
the DESIGN mode. What is going on?

Cindy

Jul 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You need to fill your dataset.
By default, a data adapter does not fill a dataset. The "Generate
Dataset" you are talking about only creates a dataset with "Strongly
Typed" tables and columns, which means your dataset has strong names
for the data in it.

To fill your dataset with data, go to the page_load event and insert
the code:

sqldataAdapter1.Fill(dataset11) ' VB, change for c#
datagrid1.Databind() ' This line ensures that every page load causes
the data to bind to the datagrid

Ideally you would wrap the above 2 lines of code in:

if Not Page.IsPostback then
end if

This is because your datagrid might use paging. There's a walkthrough
on datagrids in MSDN help. You need to do a little more work to get
paging to work, but not much.

Steve

Cindy wrote:
Hello. For some reason, I am able to "connect" to the Northwind
database whenever I use the wizard; however, when I run the
application, my datagrid does not display. Here are the exact steps I
am taking to try to get this to run:

1)New Project -->ASP.NET Application
2) From the Server Explorer, drag the Northwind Employees table onto
the WebForm1.aspx design view. SqlConnection1 and SqlDataAdapter1 are
created.
3) From the Toolbox, drag the Datagrid control onto the WebForm1.aspx
web page.
4) Click on SqlDataAdapter1 box, select "Configure Data Adapter," and
fill out the settings for my server -- server name is the only one,
check "Use Windows Integrated Security," select the Northwind database,
and click on Test Connection. Succeeded. (Funny thing: On the
"Advanced" tab, none of the permissions are checked and I can't change
them.)
5)Click next and select "Use SQL Statements" for the rest of the
wizard.
6) Keep standard query generated out of the Employees table. ("SELECT
EmployeeID, LastName, FirstName, Title, TitleOfCourtesy, BirthDate,
HireDate, Address, City, Region, PostalCode, Country, HomePhone,
Extension, Photo, Notes, ReportsTo, PhotoPath FROM Employees")
7) Finish.
8)Click on Generate Dataset. It creates Dataset11.
9) Click on the Datagrid and use the dropdown in "Datasource" to select
Dataset11.

RUN.

The explorer page is blank, even though I can see the column names in
the DESIGN mode. What is going on?

Cindy
Jul 24 '06 #2

P: n/a
Thanks! That worked perfectly!

le*********@hotmail.com wrote:
You need to fill your dataset.
By default, a data adapter does not fill a dataset. The "Generate
Dataset" you are talking about only creates a dataset with "Strongly
Typed" tables and columns, which means your dataset has strong names
for the data in it.

To fill your dataset with data, go to the page_load event and insert
the code:

sqldataAdapter1.Fill(dataset11) ' VB, change for c#
datagrid1.Databind() ' This line ensures that every page load causes
the data to bind to the datagrid

Ideally you would wrap the above 2 lines of code in:

if Not Page.IsPostback then
end if

This is because your datagrid might use paging. There's a walkthrough
on datagrids in MSDN help. You need to do a little more work to get
paging to work, but not much.

Steve

Cindy wrote:
Hello. For some reason, I am able to "connect" to the Northwind
database whenever I use the wizard; however, when I run the
application, my datagrid does not display. Here are the exact steps I
am taking to try to get this to run:

1)New Project -->ASP.NET Application
2) From the Server Explorer, drag the Northwind Employees table onto
the WebForm1.aspx design view. SqlConnection1 and SqlDataAdapter1 are
created.
3) From the Toolbox, drag the Datagrid control onto the WebForm1.aspx
web page.
4) Click on SqlDataAdapter1 box, select "Configure Data Adapter," and
fill out the settings for my server -- server name is the only one,
check "Use Windows Integrated Security," select the Northwind database,
and click on Test Connection. Succeeded. (Funny thing: On the
"Advanced" tab, none of the permissions are checked and I can't change
them.)
5)Click next and select "Use SQL Statements" for the rest of the
wizard.
6) Keep standard query generated out of the Employees table. ("SELECT
EmployeeID, LastName, FirstName, Title, TitleOfCourtesy, BirthDate,
HireDate, Address, City, Region, PostalCode, Country, HomePhone,
Extension, Photo, Notes, ReportsTo, PhotoPath FROM Employees")
7) Finish.
8)Click on Generate Dataset. It creates Dataset11.
9) Click on the Datagrid and use the dropdown in "Datasource" to select
Dataset11.

RUN.

The explorer page is blank, even though I can see the column names in
the DESIGN mode. What is going on?

Cindy
Jul 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.