Child data grid is not showing the values in the page
Posted
by prince23
on Stack Overflow
See other posts from Stack Overflow
or by prince23
Published on 2010-05-11T06:35:35Z
Indexed on
2010/05/11
9:44 UTC
Read the original article
Hit count: 286
Silverlight
|silverlight-4.0
hi,
Child data grid is not showing the values in the page for the child datagrid I am binding with an list
<sdk:DataGrid MinHeight="100" x:Name="contacts" Margin="51,21,88,98" RowDetailsVisibilityChanged="contacts_RowDetailsVisibilityChanged" LoadingRowDetails="contacts_LoadingRowDetails" RowDetailsVisibilityMode="VisibleWhenSelected" MouseLeftButtonUp="contacts_MouseLeftButtonUp" MouseLeftButtonDown="contacts_MouseLeftButtonDown">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Binding="{Binding EmployeeID}" Header="ID" />
<sdk:DataGridTextColumn Binding="{Binding EmployeeFName}" Header="Fname" />
<sdk:DataGridTextColumn Binding="{Binding EmployeeLName}" Header="LName" />
<sdk:DataGridTextColumn Binding="{Binding EmployeeMailID}" Header="MailID" />
</sdk:DataGrid.Columns>
<sdk:DataGrid.RowDetailsTemplate>
<DataTemplate>
<sdk:DataGrid x:Name="dgrdRowDetail" Width="200" AutoGenerateColumns="False" HorizontalAlignment="Center" IsReadOnly="True">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Header="CompanyName" Binding="{Binding Company name}"/>
<sdk:DataGridTextColumn Header="CompanyName" Binding="{Binding EmpID}"/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</DataTemplate>
</sdk:DataGrid.RowDetailsTemplate>
</sdk:DataGrid>
I am having 2 grids "contacts" and "dgrdRowDetail" globally i have defined an variable like this:-
DataGrid dgrdRowDetail;
in the contacts_RowDetailsVisibilityChanged
event I have this code
if (e.Row.DataContext != null)
{
string strEmpID = ((SilverlightApplication1.DBServiceEMP.Employee)((e.DetailsElement).DataContext)).EmployeeID;
dgrdRowDetail = (DataGrid)e.DetailsElement.FindName("dgrdRowDetail");
// here i am finding the child datgrid control in contacts datagrid
// then in dgrdRowDetail i will be binding this grid with new values
if (strEmpID != null)
{
int EmpID = Convert.ToInt32(strEmpID.ToString());
DBServiceEmp.GetEmployeeIDCompleted += new EventHandler<GetEmployeeIDCompletedEventArgs>(DBServiceEmp_GetEmployeeIDCompleted);
DBServiceEmp.GetEmployeeIDAsync(EmpID);
}
}
this is my method
void DBServiceEmp_GetEmployeeIDCompleted(object sender, GetEmployeeIDCompletedEventArgs e)
{
// List<Employee> Employes = new List<Employee>();
List<Employee> rows = new List<Employee>();
for (int i = 0; i < e.Result.Count; i++)
{
rows.Add(e.Result[i]);
}
dgrdRowDetail.ItemsSource = rows;
// here i am binding the child datagrid with new data source
}
dgrdRowDetail.ItemsSource = rows// what ever rows i am binding to dgrdRowDetail are not shown in the page
if i check the rows i am able to see the value ther. but in the child grid it is not reflecting
plz plz help me out i am struck
thanks in advance
prince
© Stack Overflow or respective owner