我在尝试更新只有一条记录的表时遇到问题,我使用的是 LINQ to SQL 和两个文本框。我检索记录并在页面加载时将它们显示在 texboxes 中,并且我想在用户按下 updateabout 但它没有更新时更新表。
DataClassesDataContext ss = new DataClassesDataContext();
protected void Page_Load(object sender, EventArgs e)
{
var about = (from p in ss.abouts select p).First();
if (!Page.IsPostBack)
{
txtaboutname.Text = about.title;
txtabouttext.Text = about.text;
}
}
protected void updateabout_Click(object sender, EventArgs e)
{
var about = (from p in ss.abouts select p).First();
about.title = txtaboutname.Text;
about.text = txtabouttext.Text;
ss.SubmitChanges();
}