Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to use Query string in asp.net

how to use Query string in asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasetutorialasp-nethelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kumar Rajiv
    wrote on last edited by
    #1

    how to update data in textbox control after retrieving from database and also i want to know that how to use query string to get data from database in update mode.Please help me with one example with C#.net coding and asp.net coding. rajiv

    B P 2 Replies Last reply
    0
    • K kumar Rajiv

      how to update data in textbox control after retrieving from database and also i want to know that how to use query string to get data from database in update mode.Please help me with one example with C#.net coding and asp.net coding. rajiv

      B Offline
      B Offline
      Baran M
      wrote on last edited by
      #2

      Google is the best answer. :)

      1 Reply Last reply
      0
      • K kumar Rajiv

        how to update data in textbox control after retrieving from database and also i want to know that how to use query string to get data from database in update mode.Please help me with one example with C#.net coding and asp.net coding. rajiv

        P Offline
        P Offline
        padmanabhan N
        wrote on last edited by
        #3

        //insert to database SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString()); con.Open(); string empcode = txtempcode.Text; string empname = txtEmpname.Text; SqlCommand com = new SqlCommand(); com.Connection = con; com.CommandText = "insert into ankemp values(@empcode,@empname)"; com.Parameters.Add("@empcode", empcode); com.Parameters.Add("@empname", empname); com.ExecuteNonQuery(); bindgrid(); //datasource to grid void bindgrid() { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString()); con.Open(); string query = "select * from ankemp"; SqlDataAdapter da = new SqlDataAdapter(query.ToString(), con); DataTable dt = new DataTable(); da.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } //while clicking the fetch button in grid (in aspx page protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "fetch") { int empcode = int.Parse(e.CommandArgument.ToString()); fetch(empcode); } } //fetch method public void fetch(int empcode) { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString()); con.Open(); txtempcode.Text = empcode.ToString(); StringBuilder sb = new StringBuilder(); sb.Append(" select empname, "); sb.Append(" from ankemp where empcode="+empcode); SqlCommand com = new SqlCommand(sb.ToString(), con); SqlDataReader dr = com.ExecuteReader(); if (dr.Read()) { txtEmpname.Text = dr["empname"].ToString(); } //update SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString()); con.Open(); string empcode = txtempcode.Text; string empname = txtEmpname.Text; string update = "update ankemp set empname='" + empname + "'where empcode='" + empcode + "'"; SqlCommand cmd = new SqlCommand(update, con); cmd.ExecuteNonQuery(); bindgrid(); con.Close(); //deleteing (in aspx page protected void GridView1_RowDeleting(object sender, GridViewDe

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups