Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bound Datagrid not showing up? 1

Status
Not open for further replies.

DLLHell

Programmer
May 9, 2003
69
US
I created a bound Datagrid in ASP.NET and the code below executes without failing:

dsAuthors.Clear();
oleDbDataAdapter1.Fill(dsAuthors1);

And the webpage shows up without the DataGrid. The properties Visible & Enable are true. The columns of the dataset are visible before entering Debug Mode. A "Fill DataSet" option in the Data Adapter Preview of oleDbDataAdapter shows my data.

What could be preventing the DataGrid from showing up in the Web Form?
 
I had the same problem. Check to make sure you have a connection, that the dataadapter is reading from the connection and filling a dataset. Also make sure your dataset has data, or your datagrid will show up empty.

Pose some code, and we'll take a look.
 
ConnectionString that was generated:

this.oleDbConnection1.ConnectionString = @"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=(machinename);Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=(machinename);Use Encryption for Data=False;Tag with column collation when possible=False";

Code executed (debug shows this code executing OK)
private void button1_Click(object sender, System.EventArgs e)
{
dsBV1.Clear();
oleDbDataAdapter1.Fill(dsBV1);
}

The same problem occurs when I use SQLDataAdapter - no improvements using oldDbDataAdapter. Using Windows NT Integrated Security in defining the DataAdapters.

Had to use an identity impersonate to get around the ASPNET login problem.
<identity impersonate=&quot;true&quot; userName=&quot;Domain\MyUserid&quot; password=&quot;********&quot; />
in the Web.config file.

Data shows up when Preview Data/Fill dataset is done on the data adapter. Web page always comes up without displaying the dataset.



 
Question - are you actually binding the grid after populating the dataset?

i.e.:

DataGrid.DataSource = dsAuthors;
DataGrid.DataBind();

-----------------------------------------------
&quot;The night sky over the planet Krikkit is the least interesting sight in the entire universe.&quot;
-Hitch Hiker's Guide To The Galaxy
 
Like AtomicChip said - there is no binding in the code you posted. Or maybe you bound it on a page first run (in this case, the grid should show up with data when you load your page for the first time) but forgot to bind it again on the PostBack.
 
AtomicChip - Thanks, the DataBind was missing. The examples I had in creating this DataGrid did not have DataBind mentioned or shown, so I did not think it was necessary.

Many Thanks!

My very 1st bound DataGrid. WooHoo!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top