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

Problem while displaying data using DataTable

0 Answers 7 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Manish Kumar
Top achievements
Rank 1
Manish Kumar asked on 14 Mar 2011, 02:16 PM
Hi Vlad,

I posted you my problem through other post and used your suggested DataTable. The Propblem is I am not able to display Data in the form rows in the Gridview after using DataTable I have attached the screenshot regarding the same. Please suggest me the change that is required. I read about DataTable from this post http://blogs.telerik.com/vladimirenchev/posts/09-04-23/lightweight_datatable_for_your_silverlight_applications.aspx.

I am first creating columns:
                            foreach (string time in times)
                            {
                                dataValue = new KeyValuePair(time, string.Empty);
                                //collection.Add(CreateColumn(dataValue));
                                _Table.Columns.Add(new DataColumn() { ColumnName = dataValue.Key, DataType = typeof(string) });
                            }

then setting Rows:

                                 //Row row = new Row();
                                DataRow row = new DataRow();
                                //Insert data for all the columns for each row
                                foreach (TimeDataPoint dataPoint in dataSet._Points)
                                {
                                    foreach (string time in times)
                                    {
                                        if (time != "-" && time == dataPoint._XValue)
                                        {
                                            row[time] = dataPoint._YValue.ToString();
                                            break;
                                        }
                                    }
                                }

                                _Table.Rows.Add(row);
                            }

And then setting the itemsource:

 dg.ItemsSource = _Table.ToList(); //sortableCollectionView;


thanks
Manish

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Manish Kumar
Top achievements
Rank 1
Share this question
or