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. General Programming
  3. C#
  4. search items in datagridview

search items in datagridview

Scheduled Pinned Locked Moved C#
databasehelp
5 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.
  • Z Offline
    Z Offline
    zafax_
    wrote on last edited by
    #1

    hi. I have search Textbox13 which i enter a codeNumber display it on dataGridView1. every time a new line should display after i search. i need to add new row which also searched and so on. pls help. private void searchx() { string connectionString = ConfigurationManager.ConnectionStrings["smemo.Properties.Settings.smConnectionString"].ConnectionString.ToString(); con = new SqlConnection(connectionString); string Query = "Select CodeNo,Description,Qty,P_Local,Amount from Price_list where CodeNo= " + textBox13.Text; SqlCommand cmd = new SqlCommand(Query, con); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; //DataTable dat = new DataTable(); DataSet ds = new DataSet(); da.Fill(ds,"Price_list"); // BindingSource bs = new BindingSource(); //bs.DataSource = ds.Tables["Price_list"]; dataGridView1.DataSource = ds.Tables["Price_list"]; } thanks best regards zafa

    so much of happy ending...

    P A 2 Replies Last reply
    0
    • Z zafax_

      hi. I have search Textbox13 which i enter a codeNumber display it on dataGridView1. every time a new line should display after i search. i need to add new row which also searched and so on. pls help. private void searchx() { string connectionString = ConfigurationManager.ConnectionStrings["smemo.Properties.Settings.smConnectionString"].ConnectionString.ToString(); con = new SqlConnection(connectionString); string Query = "Select CodeNo,Description,Qty,P_Local,Amount from Price_list where CodeNo= " + textBox13.Text; SqlCommand cmd = new SqlCommand(Query, con); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; //DataTable dat = new DataTable(); DataSet ds = new DataSet(); da.Fill(ds,"Price_list"); // BindingSource bs = new BindingSource(); //bs.DataSource = ds.Tables["Price_list"]; dataGridView1.DataSource = ds.Tables["Price_list"]; } thanks best regards zafa

      so much of happy ending...

      P Offline
      P Offline
      PSK_
      wrote on last edited by
      #2

      Maintain a custom collection and add the newly searched item in the list every time. Bind the data grid with the collection.

      Regards, Prakash Kalakoti

      Z 1 Reply Last reply
      0
      • Z zafax_

        hi. I have search Textbox13 which i enter a codeNumber display it on dataGridView1. every time a new line should display after i search. i need to add new row which also searched and so on. pls help. private void searchx() { string connectionString = ConfigurationManager.ConnectionStrings["smemo.Properties.Settings.smConnectionString"].ConnectionString.ToString(); con = new SqlConnection(connectionString); string Query = "Select CodeNo,Description,Qty,P_Local,Amount from Price_list where CodeNo= " + textBox13.Text; SqlCommand cmd = new SqlCommand(Query, con); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; //DataTable dat = new DataTable(); DataSet ds = new DataSet(); da.Fill(ds,"Price_list"); // BindingSource bs = new BindingSource(); //bs.DataSource = ds.Tables["Price_list"]; dataGridView1.DataSource = ds.Tables["Price_list"]; } thanks best regards zafa

        so much of happy ending...

        A Offline
        A Offline
        Arindam Tewary
        wrote on last edited by
        #3

        Though your message subject a bit different than what you want to achive ( you are actually not searching grid rather trying to display appened result :laugh: it seems ), here is how you can achive that 1. Create an empty DataTable with columns that you want to display in grid. 2. Get the seach result from DB and "append" new result set ( one or more row which comes as your search result) 3. Bind the "updated" DataTable object to grid. Let me know if you can do that. Let me know if I have misunderstood your mesasge.

        Thanks, Arindam D Tewary

        Z 1 Reply Last reply
        0
        • P PSK_

          Maintain a custom collection and add the newly searched item in the list every time. Bind the data grid with the collection.

          Regards, Prakash Kalakoti

          Z Offline
          Z Offline
          zafax_
          wrote on last edited by
          #4

          thanks Prakash.

          so much of happy ending...

          1 Reply Last reply
          0
          • A Arindam Tewary

            Though your message subject a bit different than what you want to achive ( you are actually not searching grid rather trying to display appened result :laugh: it seems ), here is how you can achive that 1. Create an empty DataTable with columns that you want to display in grid. 2. Get the seach result from DB and "append" new result set ( one or more row which comes as your search result) 3. Bind the "updated" DataTable object to grid. Let me know if you can do that. Let me know if I have misunderstood your mesasge.

            Thanks, Arindam D Tewary

            Z Offline
            Z Offline
            zafax_
            wrote on last edited by
            #5

            Thanks Arindam D Tewary . it was very helpful. you've understood best. i'll try and let me do your trick. regards zafa

            so much of happy ending...

            modified on Tuesday, March 23, 2010 12:41 PM

            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