This is a migrated thread and some comments may be shown as answers.

How to bind an List<List<String>> to the gridview ?

12 Answers 578 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aurélien Dubosson
Top achievements
Rank 1
Aurélien Dubosson asked on 20 Apr 2010, 02:40 PM
Hi everyone,

I recover with a webservice a List <List<String>> object and I would like to show this list into my Datagridview.

I try to make a Gris.ItemSource = e.result but nothing appears ;-(

What's the problem ?

Thanks a lot.

Narglix

12 Answers, 1 is accepted

Sort by
0
Aurélien Dubosson
Top achievements
Rank 1
answered on 21 Apr 2010, 12:10 PM
Anyone have an idea ?
0
Vlad
Telerik team
answered on 21 Apr 2010, 12:17 PM
Hi,

Can you post more info about your scenario? Do you get different result with standard DataGrid?

All the best,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Aurélien Dubosson
Top achievements
Rank 1
answered on 21 Apr 2010, 12:25 PM
Hi Vlad,

Thanks for your interest, also in my server side I create a list<list<String>> like that : 

SRC/DST        192.168 .1.1         192.168.1.2

192.168 .1.1

192.168.1.2

because I need a 2 dimensionnal array.

The webservice send a 2 dimensionnal array String[][] to my Silverlight's client. But when I try to bind it into my Gridview.

The result isn't good. 
0
Vlad
Telerik team
answered on 21 Apr 2010, 12:27 PM
Hello,

Why not use the approach from this blog post instead?

Best wishes,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Aurélien Dubosson
Top achievements
Rank 1
answered on 21 Apr 2010, 12:53 PM
The problem with the example is that I cannot use :

table.Columns.Cast<DataColumn>();

because my asp.net service is created with Mono and he hasn't System.Linq implemented also I cannot use Cast Function.

Is there another way ? 

Regards,

Narglix
0
Vlad
Telerik team
answered on 21 Apr 2010, 01:20 PM
Hi,

In this case you can still use List<List<String>> server-side however populate the grid on the client client using our Silverlight DataTable.

Best wishes,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Aurélien Dubosson
Top achievements
Rank 1
answered on 21 Apr 2010, 01:29 PM
How can I make that ?

Regards,
Narglix
0
Aurélien Dubosson
Top achievements
Rank 1
answered on 21 Apr 2010, 02:05 PM
I try to make it but I show the gridview but nothing inside cases. I don't understand why ?
0
Vlad
Telerik team
answered on 21 Apr 2010, 03:09 PM
Hello,

The idea is to read List<List<String>>, create our Silverlight DataTable with desired columns and rows and bind this table to the grid.

Kind regards,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Aurélien Dubosson
Top achievements
Rank 1
answered on 21 Apr 2010, 03:12 PM
I have my datatable but when I bind it into the gridview, I have the correct numbers of cell but nothing inside (no text) ;-(

My code is the following : 

 String[][] res = e.Result;
            DataTable table = new DataTable();

            for (int i = 0; i < res.Length; i++)
            {
                table.Columns.Add(new DataColumn() { ColumnName = i.ToString(), DataType = typeof(string) });
            }

            foreach(String[] s in res)
            {
                DataRow row = new DataRow();

                for (int j = 0; j < s.Length;j++ )
                {
                    System.Diagnostics.Debug.WriteLine(s[0]);
                    row[j.ToString()] = s[j];
                }
                table.Rows.Add(row);
            }
            
           

            Grid.ItemsSource = table;
0
Accepted
Vlad
Telerik team
answered on 21 Apr 2010, 03:28 PM
Hi,

You can check the attached application for reference.

All the best,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Aurélien Dubosson
Top achievements
Rank 1
answered on 21 Apr 2010, 04:07 PM
Thank you very much.

Your attachment was very usefull ;-)


Best Regards.

Aurélien Dubosson
Tags
GridView
Asked by
Aurélien Dubosson
Top achievements
Rank 1
Answers by
Aurélien Dubosson
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or