C# 检查是否有更新

C# 检查是否有更新,c#,asp.net,C#,Asp.net,网页更新数据库,但如果我没有写任何东西,他让删除数据库中的数据,我怎么能检查代码中是否有更新 protected void btnsave_Click(object sender, EventArgs e) { using (DataClasses1DataContext sdc = new DataClasses1DataContext()) { string fileName = FileUpload1.FileName; byte[] f

网页更新数据库,但如果我没有写任何东西,他让删除数据库中的数据,我怎么能检查代码中是否有更新

protected void btnsave_Click(object sender, EventArgs e)
{
    using (DataClasses1DataContext sdc = new DataClasses1DataContext()) {      
        string fileName = FileUpload1.FileName;
        byte[] fileByte = FileUpload1.FileBytes;
        Binary binaryObj = new Binary(fileByte);
        Professor_Dim prof = sdc.Professor_Dims.SingleOrDefault(x => x.P_ID == 0);
        prof.P_Fname = txtfirstname.Text;
        prof.P_Lname = txtlastname.Text;
        prof.P_Email = txtemail.Text;
        prof.P_Address = txtaddress.Text;
        prof.P_Phone = txtphone.Text;
        prof.P_Image = binaryObj;
        sdc.SubmitChanges();
    }
} 

您想使用GetChangeSet()


这将为您提供一个包含三个成员的对象、一个已更改行的列表、一个已删除行的列表和一个插入行的列表。

您想使用GetChangeSet()吗

protected void btnsave_Click(object sender, EventArgs e)
{
    using (DataClasses1DataContext sdc = new DataClasses1DataContext()) 
    {      
        string fileName = FileUpload1.FileName;
        byte[] fileByte = FileUpload1.FileBytes;
        Binary binaryObj = new Binary(fileByte);
        Professor_Dim prof = sdc.Professor_Dims.SingleOrDefault(x => x.P_ID == 0);

        if (  !string.IsNullOrEmpty(txtfirstname.Text))
            prof.P_Fname = txtfirstname.Text;

        if (  !string.IsNullOrEmpty(txtlastname.Text))
            prof.P_Lname = txtlastname.Text;

        if (  !string.IsNullOrEmpty(txtemail.Text))
            prof.P_Email = txtemail.Text;

        if (  !string.IsNullOrEmpty(txtaddress.Text))
            prof.P_Address = txtaddress.Text;

        if (  !string.IsNullOrEmpty(txtphone.Text))
            prof.P_Phone = txtphone.Text;

        prof.P_Image = binaryObj;
        sdc.SubmitChanges();
    }
} 


这将为您提供一个包含三个成员的对象、一个已更改行的列表、一个已删除行的列表和一个插入行的列表。

很难理解您想要做什么。你能把你的问题改一下吗?很难理解你想做什么。你能重新表述你的问题吗?抱歉,但是如何在我的代码中插入这个我不理解你的问题——你是在问如何使用文本编辑器?如何检查文本框中的文本还是not@AbdelrahmanShalata这是一个不同的问题——您应该发布另一个问题,关于您如何不知道
.Text
属性是什么很抱歉,但是如何在我的代码中插入这个我不明白你的问题——你是在问如何使用文本编辑器?如何检查文本框中的文本还是not@AbdelrahmanShalata这是一个不同的问题——您应该发布另一个问题,关于您如何不知道
.Text
属性是什么以及如何使用它如果这是正确答案,不要忘了标记为答案如果这是正确答案,不要忘了标记为答案
protected void btnsave_Click(object sender, EventArgs e)
{
    using (DataClasses1DataContext sdc = new DataClasses1DataContext()) 
    {      
        string fileName = FileUpload1.FileName;
        byte[] fileByte = FileUpload1.FileBytes;
        Binary binaryObj = new Binary(fileByte);
        Professor_Dim prof = sdc.Professor_Dims.SingleOrDefault(x => x.P_ID == 0);

        if (  !string.IsNullOrEmpty(txtfirstname.Text))
            prof.P_Fname = txtfirstname.Text;

        if (  !string.IsNullOrEmpty(txtlastname.Text))
            prof.P_Lname = txtlastname.Text;

        if (  !string.IsNullOrEmpty(txtemail.Text))
            prof.P_Email = txtemail.Text;

        if (  !string.IsNullOrEmpty(txtaddress.Text))
            prof.P_Address = txtaddress.Text;

        if (  !string.IsNullOrEmpty(txtphone.Text))
            prof.P_Phone = txtphone.Text;

        prof.P_Image = binaryObj;
        sdc.SubmitChanges();
    }
}