473,473 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Binding collection to a asp.net DataGrid - order of columns display question

When I bind a collection to a DataGrid (with teh single statement DataBind),
I love that the property names become the column names/values for the grid.
But I HATE that the columns are (seemingly?) displayed in random order -
i.e. I define a class with three properties: VehicleNumber, MgrLName, and
MgrFName. The grid displays as follows, which is neither the order in which
the properties were defined, or alphabetical order.

Can any one help me display these columns in the order I want
(VehicleNumber, MgrLName, and MgrFName)

MgrLName VehicleNumber MgrFName
Albritton 0294E John
Albritton 0294E John
Albritton 0294E John
private ArrayList spreadsheetSVRowsClass = new ArrayList();

ExcelVehicleColumnsSVClass colSV = new ExcelVehicleColumnsSVClass();

if (!myReader.IsDBNull((int)ExcelVehicleColumnsSV.Veh icleNum))

colSV.VehicleNumber =
myReader.GetString((int)ExcelVehicleColumnsSV.Vehi cleNum).Trim();

if (!myReader.IsDBNull((int)ExcelVehicleColumnsSV.Man agerLastName))

colSV.MgrLName =
myReader.GetString((int)ExcelVehicleColumnsSV.Mana gerLastName).Trim();

if (!myReader.IsDBNull((int)ExcelVehicleColumnsSV.Man agerFirstName))

colSV.MgrFName =
myReader.GetString((int)ExcelVehicleColumnsSV.Mana gerFirstName).Trim();

spreadsheetSVRowsClass.Add(colSV);

DataGrid1.DataSource = spreadsheetSVRowsClass;

DataGrid1.DataBind();

class ExcelVehicleColumnsSVClass

{

private string vehicleNumber;

private string mgrLName;

private string mgrFName;

public string VehicleNumber

{

get

{

return vehicleNumber;

}

set

{

vehicleNumber = value;

}

}

public string MgrLName

{

get

{

return mgrLName;

}

set

{

mgrLName = value;

}

}

public string MgrFName

{

get

{

return mgrFName;

}

set

{

mgrFName = value;

}

}

}
Nov 18 '05 #1
0 1184

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

Similar topics

0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
5
by: K | last post by:
I created a collection which is derived from ArrayList and implements IBindingList and ITypedList. Then I bound the DataSource of a data grid into the collection. It could show up the data but...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
2
by: John Sun | last post by:
Hi, Dear gurus, I want to bind my collection to a datagrid. The field names in my object show up in a weird order, and I just wonder how I could reorder those columns . I find some code like...
12
by: Daniel Walzenbach | last post by:
Hi, I want to display a Label in a DataGrid according to some condition. I therefore check whether the condition is true in the ItemDateBound EventHandler of the DataGrid. Unfortunately the...
1
by: Orlando Cavadini | last post by:
Hello I bind a collection of objects with Type AB (Class AB) to a DataGrid control as following: Public Class AB Private m_AA As Integer Private m_AB As Integer Private m_AC As Integer
8
by: Richard L Rosenheim | last post by:
I have a dataset containing a parent table related to a child table. The child table contains an ID field (which is configured as autonumber in the datatable), the ID of the parent, plus some...
1
by: Suresh | last post by:
Using ASP.NET 1.1 ---------------------- I have a custom collection of object that I'm binding to a datagrid. Each of these objects have another collection inside them. I have a user control...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.