this is my code for binding data from data base to text box
protected void Page_Load(object sender, EventArgs e)
{
label.Text = System.DateTime.Now.ToLongDateString();
////
/// date label
label.Text = System.DateTime.Now.ToLongDateString();
appSession = (String)Session["applicantEmail"];
lblusername.Text = (String)Session["applicantName"];
lblusernamepic.Text = (String)Session["applicantName"];
String str = " SELECT tblPersonalInfo.firstname, tblPersonalInfo.lastname, tblPersonalInfo.fathername, tblPersonalInfo.country, tblPersonalInfo.city, tblPersonalInfo.phoneno,tblPersonalInfo.mobno, tblPersonalInfo.domicile, tblPersonalInfo.sect, tblPersonalInfo.cnicnum, tblPersonalInfo.mailingadd, tblPersonalInfo.permanentadd,tblUser.fullname, tblUser.email, tblUser.password, tblUser.question, tblUser.answers, tblUser.gender, tblUser.dob, tblUser.doc FROM tblPersonalInfo INNER JOIN tblUser ON tblPersonalInfo.userid = tblUser.userid WHERE roleid=3 and (tblUser.email = '" + (String)Session["applicantEmail"] + "')";
//String str = "select fullname,email,password,question,answers,gender,dob,doc from tblUser where roleid=3 and email='" + (String)Session["applicantEmail"] + "'";
SqlCommand cmd = new SqlCommand(str, con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
txtfullname.Text = dr["fullname"].ToString();
txtemail.Text = dr["email"].ToString();
txtpassword.Text = dr["password"].ToString();
txtquestion.Text = dr["question"].ToString();
txtanswer.Text = dr["answers"].ToString();
txtgender.Text = dr["gender"].ToString();
txtdob.Text = dr["dob"].ToString();
txtaccountcreate.Text = dr["doc"].ToString();
txtfirstname.Text = dr["firstname"].ToString();
txtlastname.Text = dr["lastname"].ToString();
txtfathername.Text = dr["fathername"].ToString();
txtcountry.Text = dr["country"].ToString();
txtcity.Text = dr["city"].ToString();
txtphoneno.Text = dr["phoneno"].ToString();
txtmob.Text = dr["mobno"].ToString();
txtdomicile.Text = dr["domicile"].ToString();
txtsect.Text = dr["sect"].ToString();
txtmailingaddress.Text = dr["mailingadd"].ToString();
txtpermanent.Text = dr["permanentadd"].ToString();
}
con.Close();
if (!IsPostBack)
{
BindAcademicDetails();
BindExperienceDetails();
BindPublicationsDetails();
}
}
is there any solution that the above bind data when changed by user and i get it for updating...???
protected void update_Click(object sender, EventArgs e)
{
userid = Convert.ToInt32(Session["userid"]);
username = (String)Session["applicantName"];
con.Open();
SqlCommand cmd = new SqlCommand("update tblUser set fullname='" + txtfullname.Text + "' where userid=" + userid, con);
cmd.ExecuteNonQuery();
con.Close();
}
thanks in Advance !!