Sreenath G

Sreenath G

  • NA
  • 233
  • 310.7k

Issue in CSV loading to Silverlight datagrid

May 12 2011 2:39 AM
 

Hi,

I am now blank with this issue. After loading the whole data, all the rows are showing blank in grid. Here is my code..

Please help out where I am doing mistake…all the rows been filled in grid are showing blank..

Grid definition…

<sdk:DataGrid  Name="dgrIncidents"   AutoGenerateColumns="False"  HeadersVisibility="All"

                                                RowBackground="Cornsilk" AlternatingRowBackground="LemonChiffon"

                                                 IsReadOnly="True" CanUserResizeColumns="True" GridLinesVisibility="All">

                            <sdk:DataGrid.Columns>

                                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="Reported Date" Binding="{Binding Reported_Date}"/>

                                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="Incident ID" Binding="{Binding Incident_ID}"/>

                                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="Closed Date" Binding="{Binding Closed_Date}"/>

                                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="Last Resolved Date" Binding="{Binding Last_Resolved_Date}"/>

                                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="Assigned Group" Binding="{Binding Assigned_Group}"/>

                                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="Assignee" Binding="{Binding Assignee}"/>

                                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="Status" Binding="{Binding Status}"/>

                                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="Summary" Binding="{Binding Summary}"/>

                            </sdk:DataGrid.Columns>

                        </sdk:DataGrid>

 

Back code

 

void lFnLoadDataInGrid()

        {

            try

            {

                lFnStartWait();

                dgrIncidents.ItemsSource = lFnLoadCSVDataInGrid();

                lFnStopWait();

            }

            catch (Exception)

            {

 

                throw;

            }

        }

 

 

        List<clsGridLoadExcelData> lFnLoadCSVDataInGrid()

        {

            try

            {

                if (Prp_Opendialogue.File == null)

                {

                    lFnShowPopupErr("Please select CSV file");

                    return null;

                }

 

                List<clsGridLoadExcelData> lArrObjclsGridLoadExcelData = new List<clsGridLoadExcelData>();

 

                StreamReader lObjStreamReader = new StreamReader(Prp_Opendialogue.File.OpenRead());

 

                bool lBlnIsColumnRow = true;

 

                while (lObjStreamReader.Read() != null)

                {

                    string lStrLine = lObjStreamReader.ReadLine();

 

                    if (lBlnIsColumnRow)

                    {

                        lBlnIsColumnRow = false;

                        continue;

                    }

 

                    if (lStrLine == null)

                        break;

 

                    if (lStrLine.Trim() == "")

                        continue;

 

                    string[] lArrStrCells = null;

 

                    lArrStrCells = lStrLine.Split(",".ToCharArray());

 

                    if (lArrStrCells == null)

                        continue;

 

                    if (!(lArrStrCells.Length == 8))

                        continue;

 

                    clsGridLoadExcelData lObjclsGridLoadExcelData = new clsGridLoadExcelData();

 

                    lObjclsGridLoadExcelData.Reported_Date = lArrStrCells[0];

                    lObjclsGridLoadExcelData.Incident_ID = lArrStrCells[1];

                    lObjclsGridLoadExcelData.Closed_Date = lArrStrCells[2];

                    lObjclsGridLoadExcelData.Last_Resolved_Date = lArrStrCells[3];

                    lObjclsGridLoadExcelData.Assigned_Group = lArrStrCells[4];

                    lObjclsGridLoadExcelData.Assignee = lArrStrCells[5];

                    lObjclsGridLoadExcelData.Status = lArrStrCells[6];

                    lObjclsGridLoadExcelData.Summary = lArrStrCells[7];

 

                    lArrObjclsGridLoadExcelData.Add(lObjclsGridLoadExcelData);

                }

 

                lObjStreamReader.Close();

                lObjStreamReader.Dispose();

 

                return lArrObjclsGridLoadExcelData;

            }

            catch (Exception ex)

            {

                lFnShowPopupErr(ex.Message.ToString());

                return null;

            }

        }

 

   class clsGridLoadExcelData

        {

 

 

            public string Reported_Date { get; set; }

            public string Incident_ID { get; set; }

            public string Closed_Date { get; set; }

            public string Last_Resolved_Date { get; set; }

            public string Assigned_Group { get; set; }

            public string Assignee { get; set; }

            public string Status { get; set; }

            public string Summary { get; set; }

 

 

 

        }

 

Thanks

Sreenath


Answers (4)