Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am binding a data grid control to an array list that was populated via a data reader. The code is below

 

 

while (dataReader.Read())

{

Company company = new Company(dataReader.GetString(0), dataReader.GetString(1), dataReader.GetString(2));

 

companies.Add(company);

}

 

}

this.dgTest.DataSource = companies;

 

This first item in the data reader is the CompanyID, 2nd is CompanyName, and 3rd is ContactName.

 

When the data is displayed in the data grid the columns are reversed - ie the 1st column is ContactName, 2nd column is CompanyName, and 3rd is CompanyID.

 

How do I populate the data grid so the columns are in the same order as the data reader?

 

Thanks.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...