I would like to give you an idea of solving the problem in ASP.Net4 and SQL Server 2008 with entity framework concept.
Table name: User, Entity model name: "UserModel", & Entity Name: UserEntity. Code for the "aspx.cs" page:
using System;
..........
..........
using UserModel;
protected void btnInsertUpdate_Click(object sender, EventArgs e)
{
using(UserEntity myEntity=new UserEntity())
{
User NUser=new User();
int UID=Covert.ToInt32(txtUID.Text);
NUser=(from u in myEntity.Users where u.user_ID==UID selet u).SingleOrDefault();
if(NUser==null)
{
User NewUser=new User();
NewUser.User_ID=UID;
NewUser.user_name=txtuser_name.text;
NUser.Phone_number=convert.ToInt32(txtPhone_number.text);
..........................;
..........................;
..........................;
myEntity.AddToUsers(NewUser);
myEntity.SaveChanges();
}
else
{
NUser.user_name=txtuser_name.text;
NUser.Phone_number=convert.ToInt32(txtPhone_number.text);
...............;
................;
................;
myEntity.SaveChanges();
}
}
}
Hope, it will sort out your problem.