代码有误求解
using System;using System.Collections.Generic;
using System.Linq;
using
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SL_31102017.Web;
namespace SL_31102017
{
public partial class MainPage : UserControl
{
DomainService1 m_ds =null;
public MainPage()
{
InitializeComponent();
m_ds.Load(m_ds.GetStudentsQuery());
m_ds = new DomainService1();
m_ds.Load(m_ds.GetStudentsQuery());
dg_装载数据.ItemsSource = m_ds.students;
}
private void bt_增加_Click(object sender, RoutedEventArgs e)
{
student sd = new student();
sd.编号 = Convert.ToInt32(tb_编号.Text);
sd.出勤期 = Convert.ToDateTime(tb_出勤期.Text);
sd.年龄 = Convert.ToInt32(tb_年龄.Text);
sd.姓名 = Convert.ToString(tb_姓名);
m_ds.students.Add(sd);
m_ds.SubmitChanges();
if (rb_男.IsChecked == true)
{
sd.性别 = Convert.ToBoolean("true");
}
else
{
sd.性别 = Convert.ToBoolean("false");
}
if (tb_编号.Text == "" && tb_出勤期.Text == "" && tb_年龄.Text == "" && tb_姓名.Text == "")
{
MessageBox.Show("您未添加任何数据!");
}
}
private void bt_修改_Click(object sender, RoutedEventArgs e)
{
student sd =(student)dg_装载数据.SelectedItem;
sd.编号 = Convert.ToInt32(tb_编号.Text);
sd.出勤期 = Convert.ToDateTime(tb_出勤期.Text);
sd.年龄 = Convert.ToInt32(tb_年龄.Text);
sd.姓名 = Convert.ToString(tb_姓名);
m_ds.SubmitChanges();
}
private void bt_删除_Click(object sender, RoutedEventArgs e)
{
student sd = (student)dg_装载数据.SelectedItem;
m_ds.students.Remove(sd);
m_ds.SubmitChanges();
}
private void bt_退出_Click(object sender, RoutedEventArgs e)
{
}
}
}
这句代码有误
m_ds.Load(m_ds.GetStudentsQuery());(未能将对象引用到对象实例)