Click here to Skip to main content
12,360,526 members (58,217 online)
Rate this:
 
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@ 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 14 Mar 2012
Copyright © CodeProject, 1999-2016
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