首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

Silverlight+ WCF RIA Service 数据添加 求教解决思路

2012-05-15 
Silverlight+ WCF RIA Service 数据添加 求教前台C# codeGrid x:NameLayoutRootButton ContentBut

Silverlight+ WCF RIA Service 数据添加 求教
前台

C# code
<Grid x:Name="LayoutRoot">                <Button Content="Button" Height="23" Name="button3" Width="75" Click="button3_Click" />                <sdk:DataGrid x:Name="dg1" ItemsSource="{Binding Data, ElementName=TaskDetailDataSource}" DataContext="{Binding Data}" Width="500" Height="400">                    <sdk:DataGrid.Columns>                        <sdk:DataGridTextColumn Header="ID" Width="120" Binding="{Binding TaskID, Mode=OneWay}" IsReadOnly="True"></sdk:DataGridTextColumn>                        <sdk:DataGridTextColumn Header="经度" Width="150" Binding="{Binding Longitude, Mode=TwoWay}" IsReadOnly="True"></sdk:DataGridTextColumn>                        <sdk:DataGridTextColumn Header="纬度" Width="150" Binding="{Binding Latitude, Mode=TwoWay}" IsReadOnly="True"></sdk:DataGridTextColumn>                        <sdk:DataGridTextColumn Header="排序" Width="120" Binding="{Binding Sort, Mode=TwoWay}" IsReadOnly="True"></sdk:DataGridTextColumn>                    </sdk:DataGrid.Columns>                </sdk:DataGrid>        <riaControls:DomainDataSource Name="TaskDetailDataSource" QueryName="GetTaskDetailQuery" LoadSize="20"  AutoLoad="True" >            <riaControls:DomainDataSource.DomainContext>                <ds:ParkerDomainContext/>            </riaControls:DomainDataSource.DomainContext>        </riaControls:DomainDataSource>    </Grid>


后台
C# code
ParkerDomainContext _context = new ParkerDomainContext();        private void button3_Click(object sender, RoutedEventArgs e)        {          //  ParkerDomainContext _context = (ParkerDomainContext)(TaskDetailDataSource.DataContext);            TaskDetail taskDetail = new TaskDetail();            taskDetail.TaskID = 1;            taskDetail.Latitude = 50;            taskDetail.Longitude = 50;            _context.TaskDetails.Add(taskDetail);            //TaskDetailDataSource.DataContext = _context.TaskDetails;            TaskDetailDataSource.SubmitChanges();        }



为什么不能添加 数据 到 数据库

[解决办法]
//TaskDetailDataSource.DataContext = _context.TaskDetails;
这句不能屏蔽吧
[解决办法]
探讨
前台C# code

<Grid x:Name="LayoutRoot">
<Button Content="Button" Height="23" Name="button3" Width="75" Click="button3_Click" />
<sdk:DataGrid x:Name="dg1" ItemsSource="{……

热点排行