This question is locked. New answers and comments are not allowed.
Hi
I am developing a silverlight (Version 4) navigation application with
1. MVVM pattern
2. PRISM 4 framework
3. RIA services
4. Telerik Silverlight Controls (latest version)
I am using following code to update the entity data using Context.
There is a page known a Familay details. In this page i have to show the family members data in RadGridview at the time of load.
I am using the following code.
<telerik:RadGridView x:Name="FamilyDetails" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto" RowIndicatorVisibility="Collapsed" ItemsSource="{Binding FamilyMember, Mode=TwoWay}"
AlternateRowBackground="AliceBlue" AlternationCount="2" AutoGenerateColumns="False" HorizontalAlignment="Left"
ShowGroupPanel="False" Margin="10" Width="940" VerticalAlignment="Top" RowHeight="30" MinHeight="100" >
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Name" IsResizable="False" IsReadOnly="True" Width="400" DataMemberBinding="{Binding FamilyMemberName,Mode=TwoWay}" ></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Date of Birth" IsResizable="False" IsReadOnly="True" Width="200" DataMemberBinding="{Binding DOB,Mode=TwoWay}" ></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="RelationShip Type" IsResizable="False" IsReadOnly="True" Width="200" DataMemberBinding="{Binding Description,Mode=TwoWay}" ></telerik:GridViewDataColumn>
<telerik:GridViewColumn Header="Action" IsResizable="False" Width="140">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
<telerik:RadButton Width="30" Height="30" HorizontalAlignment="Left" Command="{Binding EditCommand, Source={StaticResource fvVM}}" CommandParameter="{Binding PatientId}" Background="Transparent" >
<Image Name="img1" Width="24" Height="24" Source="/OT.Patient;component/Asset/Image/edit.png"></Image>
</telerik:RadButton>
<telerik:RadButton Width="30" Height="30" HorizontalAlignment="Left" Command="{Binding DeleteCommand, Source={StaticResource fvVM}}" CommandParameter="{Binding PatientId}" Margin="20,0,0,0" Background="Transparent" >
<Image Name="img2" Width="24" Height="24" Source="/OT.Patient;component/Asset/Image/delete.png"></Image>
</telerik:RadButton>
</StackPanel>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
******************************************************************************************************************
The datacontext for view will set using property in XAML file code behind as
******************************************************************************************************
[Export(typeof(FamilyDetailView))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public partial class FamilyDetailView : UserControl
{
public FamilyDetailView()
{
InitializeComponent();
}
[Import]
public FamilyDetailViewModel ViewModel
{
get { return this.DataContext as FamilyDetailViewModel; }
set { this.DataContext = value; }
}
}
*************************************************************************************************************
In ViewModel
[ImportingConstructor]
public FamilyDetailViewModel(IRegionManager regionManager)
{
this.DivVisiblity = Visibility.Collapsed;
_regionManager = regionManager;
PatientDataContext Context = new PatientDataContext();
var Query = Context.GetVw_GetFamilyMembersQuery();
Context.Load(Query, LoadBehavior.RefreshCurrent, MyCallBack, null);
}
private void MyCallBack(LoadOperation lo)
{
if (!lo.HasError)
{
var entityList = lo.Entities.Where(i => i is vw_GetFamilyMembers).Cast<vw_GetFamilyMembers>().ToList();
var entity2 = entityList.Where(t => t.ParentPatientId == LoginUser.ID).ToList();
this.FamilyMember = new ObservableCollection<vw_GetFamilyMembers>(entity2);
this.OnPropertyChanged("FamilyMember");
}
}
*********************************************************************************************
The above code will successfully bind my grid and display data properly.
But the problem is i have to update the grid data after inserting a new data in Entity using datacontext of Ria service(table).
we are uding follwoing code to update the context.
***********************************************************
context.Patients.Add(this.FamilyPatients);
context.SubmitChanges();
***********************************************************
After executing the code the updated data will saved in database (Sql 2008).
But the RadGridview is not showing the updated data.
I will used the
this.OnPropertyChanged("FamilyMember");
after updating the record.
Please suggest me where i am getting the problem.
I am developing a silverlight (Version 4) navigation application with
1. MVVM pattern
2. PRISM 4 framework
3. RIA services
4. Telerik Silverlight Controls (latest version)
I am using following code to update the entity data using Context.
There is a page known a Familay details. In this page i have to show the family members data in RadGridview at the time of load.
I am using the following code.
- In VIew:
<telerik:RadGridView x:Name="FamilyDetails" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto" RowIndicatorVisibility="Collapsed" ItemsSource="{Binding FamilyMember, Mode=TwoWay}"
AlternateRowBackground="AliceBlue" AlternationCount="2" AutoGenerateColumns="False" HorizontalAlignment="Left"
ShowGroupPanel="False" Margin="10" Width="940" VerticalAlignment="Top" RowHeight="30" MinHeight="100" >
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Name" IsResizable="False" IsReadOnly="True" Width="400" DataMemberBinding="{Binding FamilyMemberName,Mode=TwoWay}" ></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Date of Birth" IsResizable="False" IsReadOnly="True" Width="200" DataMemberBinding="{Binding DOB,Mode=TwoWay}" ></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="RelationShip Type" IsResizable="False" IsReadOnly="True" Width="200" DataMemberBinding="{Binding Description,Mode=TwoWay}" ></telerik:GridViewDataColumn>
<telerik:GridViewColumn Header="Action" IsResizable="False" Width="140">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
<telerik:RadButton Width="30" Height="30" HorizontalAlignment="Left" Command="{Binding EditCommand, Source={StaticResource fvVM}}" CommandParameter="{Binding PatientId}" Background="Transparent" >
<Image Name="img1" Width="24" Height="24" Source="/OT.Patient;component/Asset/Image/edit.png"></Image>
</telerik:RadButton>
<telerik:RadButton Width="30" Height="30" HorizontalAlignment="Left" Command="{Binding DeleteCommand, Source={StaticResource fvVM}}" CommandParameter="{Binding PatientId}" Margin="20,0,0,0" Background="Transparent" >
<Image Name="img2" Width="24" Height="24" Source="/OT.Patient;component/Asset/Image/delete.png"></Image>
</telerik:RadButton>
</StackPanel>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
******************************************************************************************************************
The datacontext for view will set using property in XAML file code behind as
******************************************************************************************************
[Export(typeof(FamilyDetailView))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public partial class FamilyDetailView : UserControl
{
public FamilyDetailView()
{
InitializeComponent();
}
[Import]
public FamilyDetailViewModel ViewModel
{
get { return this.DataContext as FamilyDetailViewModel; }
set { this.DataContext = value; }
}
}
*************************************************************************************************************
In ViewModel
[ImportingConstructor]
public FamilyDetailViewModel(IRegionManager regionManager)
{
this.DivVisiblity = Visibility.Collapsed;
_regionManager = regionManager;
PatientDataContext Context = new PatientDataContext();
var Query = Context.GetVw_GetFamilyMembersQuery();
Context.Load(Query, LoadBehavior.RefreshCurrent, MyCallBack, null);
}
private void MyCallBack(LoadOperation lo)
{
if (!lo.HasError)
{
var entityList = lo.Entities.Where(i => i is vw_GetFamilyMembers).Cast<vw_GetFamilyMembers>().ToList();
var entity2 = entityList.Where(t => t.ParentPatientId == LoginUser.ID).ToList();
this.FamilyMember = new ObservableCollection<vw_GetFamilyMembers>(entity2);
this.OnPropertyChanged("FamilyMember");
}
}
*********************************************************************************************
The above code will successfully bind my grid and display data properly.
But the problem is i have to update the grid data after inserting a new data in Entity using datacontext of Ria service(table).
we are uding follwoing code to update the context.
***********************************************************
context.Patients.Add(this.FamilyPatients);
context.SubmitChanges();
***********************************************************
After executing the code the updated data will saved in database (Sql 2008).
But the RadGridview is not showing the updated data.
I will used the
this.OnPropertyChanged("FamilyMember");
after updating the record.
Please suggest me where i am getting the problem.