Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
This is my code
protected void Page_Load(object sender, EventArgs e)
    {
        userdetails();
 
    }
   
   
    public void userdetails()
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from freeuserdetails where UserName='" + Session["username"] + "'", con);
        SqlDataReader dr = cmd.ExecuteReader();
        if (dr.Read())
        {
            txtuname.Text = dr["UserName"].ToString();            
            txtmailid.Text = dr["MailId"].ToString();
            txtdob.Text = dr["DOB"].ToString();
            txtmobileno.Text = dr["MobileNo"].ToString();
            txtaddress.Text = dr["Address"].ToString();
            cmd.Dispose();
            
        }
        con.Close();
 
    }
    protected void btnupdate_Click(object sender, ImageClickEventArgs e)
    {
        
        
        con.Open();
        SqlCommand cmd = new SqlCommand("update freeuserdetails set MailId='" + txtmailid.Text + "',DOB='" + txtdob.Text + "',MobileNo='" + txtmobileno.Text + "',Address='" + txtaddress.Text + "' where UserName='" + txtuname.Text + "'", con);
        cmd.ExecuteNonQuery();
        con.Close();
    }
 
if i click the update button the old database values are updated ........
How to update the database values...
Posted 13-Mar-12 21:11pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

 
//Call userdetails() funtion in page load

if(!IsPostBack)
{
userdetails();
}
 
  Permalink  
Comments
S@R@V@N@ at 14-Mar-12 3:22am
   
Thank You

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 359
1 _Amy 230
2 OriginalGriff 200
3 Manfred R. Bihy 200
4 Peter Leow 180
0 OriginalGriff 7,495
1 Sergey Alexandrovich Kryukov 6,402
2 Maciej Los 3,849
3 Peter Leow 3,568
4 CHill60 2,702


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 14 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100