Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have filled the itemsource with List of class whose variables are same as datagrid columns. But after assigning itemsource to datagrid, grid is showing total rows but there is not data in that rows(infact empty rows are displayed whereas item source list has got data).


Any remedy for this issue. Please suggest.

Update 1:

Here are more details..
Grid definition..

XML
<sdk:DataGrid Name="dgrIncidents" AutoGenerateColumns="False" IsReadOnly="True" >
<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>


and the item soruce class..

C#
class clsGridLoadExcelData
{
public string _Reported_Date = "";
public string _Incident_ID = "";
public string _Closed_Date = "";
public string _Last_Resolved_Date = "";
public string _Assigned_Group = "";
public string _Assignee = "";
public string _Status = "";
public string _Summary = "";
public string Reported_Date
{
get





{
return _Reported_Date;
}
set

{
_Reported_Date = value;
}
}
public string Incident_ID
{
get

{
return _Incident_ID;
}
set

{
_Incident_ID = value;
}
}
public string Closed_Date
{
get

{
return _Closed_Date;
}
set

{
_Closed_Date = value;
}
}
public string Last_Resolved_Date
{
get

{
return _Last_Resolved_Date;
}
set

{
_Last_Resolved_Date = value;
}
}
public string Assigned_Group
{
get

{
return _Assigned_Group;
}
set

{
_Assigned_Group = value;
}
}
public string Assignee
{
get

{
return _Assignee;
}
set

{
_Assignee = value;
}
}
public string Status
{
get

{
return _Status;
}
set

{
_Status = value;
}
}
public string Summary
{
get

{
return _Summary;
}
set

{
_Summary = value;
}
}

}


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


this will be my grids item source..any help now plzz..

Thanks
Posted
Updated 9-May-11 4:10am
v3

You need to specify DisplayMemeberPath Binding (or similar) for each columns in the DataGrid

Update 1:
Did you binded the lArrObjclsGridLoadExcelData object to the DataGrid's ItemsSource property?

You can binding like,

C#
dgrIncidents.ItemsSource = lArrObjclsGridLoadExcelData;


or
C#
Binding binding = new Binding();
binding.Source = lArrObjclsGridLoadExcelData;
dgrIncidents.SetBinding(DataGrid.ItemsSourceProperty, binding);
 
Share this answer
 
v3
Comments
Sreenath Gv 9-May-11 7:27am    
please find my grid definition below..can you quote the mistake..
Venkatesh Mookkan 9-May-11 10:15am    
Updated the answer.
Sreenath Gv 9-May-11 13:00pm    
yeah, I have done this.. dgrIncidents.ItemsSource = lArrObjclsGridLoadExcelData;...but even then all the rows are not displaying data..
Define a Datatemplate. OR set autogeneratecolumns to true.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900