473,785 Members | 3,417 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid: Bind to an Enumerator of object[]'s

Hi guys,

I've an Enumerator of object arrays that I need to display on a DataGrid.
Unfortunately, after I set the DataSource to the Enumerator, and call
DataBind(), the DataGrid picks up & displays the public properties of the
object[] instance :(

I'm not able to specify in advance how big the array will be, or what sort
of data is contained in it unfortunately, so I couldn't just create a
"wrapper" object around the array with public properties.

On the other hand, the grid displays a DataSet correctly, which doesn't have
pre-defined columns as well. So there must be a way to tell the DataGrid
both the column names, and how to read them from the "row" object ( my
object[] in this case ) but ... I've no idea how :?

Any pointers pls ?

Cheers,
Angel
O:]
Nov 18 '05 #1
1 1116
Ela na sou po...:-)

The best way is to create your own datagrid (inherit .NET datagrid) in
order to manage the data the way you want.

You must create a wrapper there to translate each kind of object Row
you have to display.

Pay attention at OnItemCreated, and OnItemDataBound events of Grid

"Angelos Karantzalis" <ak**********@y ahoo.com> wrote in message news:<uR******* *******@tk2msft ngp13.phx.gbl>. ..
Hi guys,

I've an Enumerator of object arrays that I need to display on a DataGrid.
Unfortunately, after I set the DataSource to the Enumerator, and call
DataBind(), the DataGrid picks up & displays the public properties of the
object[] instance :(

I'm not able to specify in advance how big the array will be, or what sort
of data is contained in it unfortunately, so I couldn't just create a
"wrapper" object around the array with public properties.

On the other hand, the grid displays a DataSet correctly, which doesn't have
pre-defined columns as well. So there must be a way to tell the DataGrid
both the column names, and how to read them from the "row" object ( my
object[] in this case ) but ... I've no idea how :?

Any pointers pls ?

Cheers,
Angel
O:]

Nov 18 '05 #2

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

Similar topics

0
1336
by: Oliver Hopton | last post by:
Hello, I'm trying to write a PageableCollection class which implements paging for me so I don't need to rely on the paging provided by the DataGrid as that generates huge viewstate when bound to a collection with a lot of items. The code below works fine when I use foreach to iterate over it but when I bind the Datagrid to an instance of this class I get the whole collection displayed in the grid! Does the Datagrid not use...
0
473
by: Steve | last post by:
I have a datagrid that is created at run time DataGrid dgG = new DataGrid(); BoundColumn bcB; dgG.CellPadding = 5; dgG.CellSpacing = 0; dgG.GridLines = GridLines.Both; dgG.CssClass = "SectionTableLines"; dgG.DataKeyField = "PlanWorkOrderID";
3
1658
by: Just D | last post by:
Hi, If anybody needs to show some data retrieved from the database table, what method is more preferrable? 1. DataSet ds = ...; DataGrid.Data.Source.ds; DataGrid.Bind(); 2. Write a custom object, fill it with the DataSet data and ÅÒÕÔ try to bind
5
2793
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go to the database to get the next page. Is there a way to use the dataset to allow us to read back and forth in it instead of going back to the database to get it? Thanks,
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
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 we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.