Home All Groups Group Topic Archive Search About

ASP.net datagrid with more than 1 datasource

Author
14 Jun 2005 9:12 AM
Jimmy
Hi

Is it possible to build a datagrid with one column having test1 as a
datasource and another column having test2 as  a datasource:
string[] test1 = new string[]{"1", "2", "3"};

string[] test2 = new string[]{"John", "Marc", "Tom"};



I just want a table that looks like this:



1    John

2    Marc

3    Tom



Is this possible with a WebDatagrid or do i have to use another object?



Regards



Jim

Author
14 Jun 2005 1:26 PM
Brock Allen
When data binding, the grid can only cope wiht one data source at a time.
You'll have to merge your two data sources into one.

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> Hi
>
> Is it possible to build a datagrid with one column having test1 as a
> datasource and another column having test2 as  a datasource: string[]
> test1 = new string[]{"1", "2", "3"};
>
> string[] test2 = new string[]{"John", "Marc", "Tom"};
>
> I just want a table that looks like this:
>
> 1    John
>
> 2    Marc
>
> 3    Tom
>
> Is this possible with a WebDatagrid or do i have to use another
> object?
>
> Regards
>
> Jim
>
Author
14 Jun 2005 1:30 PM
Brock Allen
> When data binding, the grid can only cope wiht one data source at a
> time. You'll have to merge your two data sources into one.

Or the other thing you could do is to manually iterate over your datasources
and manually build the Grid.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Author
14 Jun 2005 3:38 PM
Patrice
It looks like you are using two distinct arrays to store related
information. IMO it would be really better to have an array with structures
or classes in such a case. Not only it should solve the problem (plus for
example if you want to sort or whatever else it will be easier to have a
"row of data" in each cell rather than having n array each one storing just
a column).

Patrice

--

Show quoteHide quote
"Jimmy" <bef***@gmail.com> a écrit dans le message de
news:uI7g9EMcFHA.3184@TK2MSFTNGP15.phx.gbl...
> Hi
>
> Is it possible to build a datagrid with one column having test1 as a
> datasource and another column having test2 as  a datasource:
> string[] test1 = new string[]{"1", "2", "3"};
>
> string[] test2 = new string[]{"John", "Marc", "Tom"};
>
>
>
> I just want a table that looks like this:
>
>
>
> 1    John
>
> 2    Marc
>
> 3    Tom
>
>
>
> Is this possible with a WebDatagrid or do i have to use another object?
>
>
>
> Regards
>
>
>
> Jim
>
>