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. datagridview

datagridview

Scheduled Pinned Locked Moved C#
csharpsalesquestioncareer
14 Posts 5 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 kulandaivel_mca2007

    i am using windows aplliction using c#... i have 1000 records in my table.... which has fields CUSTOMER_ID,NAME,CITY,SALARY..... I HAVE TO SEE ONLY THE CUSTOMER WHO ARE LIVING THE CITY CALLED "DOWNTOWN" HOW CAN I SEE THIS IN DATAGRIDVIEW... PLS REPLY... GIVE ME SUGGESTION OR SAMPLE CODING... THNX IN ADVANCE

    T Offline
    T Offline
    tasumisra
    wrote on last edited by
    #2

    on load of the screen or where ever you are loading the grid just before binding to the dataGrid you can loop through each row and check the condtion where Rows[0].Cells[0].tostring()=="xyz"

    vikas da

    H 1 Reply Last reply
    0
    • K kulandaivel_mca2007

      i am using windows aplliction using c#... i have 1000 records in my table.... which has fields CUSTOMER_ID,NAME,CITY,SALARY..... I HAVE TO SEE ONLY THE CUSTOMER WHO ARE LIVING THE CITY CALLED "DOWNTOWN" HOW CAN I SEE THIS IN DATAGRIDVIEW... PLS REPLY... GIVE ME SUGGESTION OR SAMPLE CODING... THNX IN ADVANCE

      L Offline
      L Offline
      Lev Danielyan
      wrote on last edited by
      #3

      Hi, Why don't you use the BindingSource Filter property? For example, you can have myDataSource.Filter = "City = 'DOWNTOWN'" Here is the example from MSDN: private void PopulateDataViewAndFilter() { DataSet set1 = new DataSet(); // Some xml data to populate the DataSet with. string musicXml = "" + "" + "ColdplayX&Y" + "Dave MatthewsUnder the Table and Dreaming" + "Dave MatthewsLive at Red Rocks" + "Natalie MerchantTigerlily" + "U2How to Dismantle an Atomic Bomb" + ""; // Read the xml. StringReader reader = new StringReader(musicXml); set1.ReadXml(reader); // Get a DataView of the table contained in the dataset. DataTableCollection tables = set1.Tables; DataView view1 = new DataView(tables[0]); // Create a DataGridView control and add it to the form. DataGridView datagridview1 = new DataGridView(); datagridview1.AutoGenerateColumns = true; this.Controls.Add(datagridview1); // Create a BindingSource and set its DataSource property to // the DataView. BindingSource source1 = new BindingSource(); source1.DataSource = view1; // Set the data source for the DataGridView. datagridview1.DataSource = source1; source1.Filter = "artist = 'Dave Matthews'"; }

      Regards, Lev

      1 Reply Last reply
      0
      • T tasumisra

        on load of the screen or where ever you are loading the grid just before binding to the dataGrid you can loop through each row and check the condtion where Rows[0].Cells[0].tostring()=="xyz"

        vikas da

        H Offline
        H Offline
        Harvey Saayman
        wrote on last edited by
        #4

        :wtf: are you insane? I would hate to see crap like that in a program i have to maintain...

        Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

        T 1 Reply Last reply
        0
        • K kulandaivel_mca2007

          i am using windows aplliction using c#... i have 1000 records in my table.... which has fields CUSTOMER_ID,NAME,CITY,SALARY..... I HAVE TO SEE ONLY THE CUSTOMER WHO ARE LIVING THE CITY CALLED "DOWNTOWN" HOW CAN I SEE THIS IN DATAGRIDVIEW... PLS REPLY... GIVE ME SUGGESTION OR SAMPLE CODING... THNX IN ADVANCE

          H Offline
          H Offline
          Harvey Saayman
          wrote on last edited by
          #5

          Assuming the 1000 rows are coming from a data base, you have two options... 1) Query only the data your looking for and not everything, remember "any monkey can SELECT * FROM 2) Use a DataView to filter out the data you want to display

          Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

          1 Reply Last reply
          0
          • H Harvey Saayman

            :wtf: are you insane? I would hate to see crap like that in a program i have to maintain...

            Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

            T Offline
            T Offline
            tasumisra
            wrote on last edited by
            #6

            are you mental.. go to some hospital..:) bloddy this was just a suggestion if you know something better then me .. did i stop you to answer...

            vikas da

            H 1 Reply Last reply
            0
            • T tasumisra

              are you mental.. go to some hospital..:) bloddy this was just a suggestion if you know something better then me .. did i stop you to answer...

              vikas da

              H Offline
              H Offline
              Harvey Saayman
              wrote on last edited by
              #7

              tasumisra wrote:

              did i stop you to answer

              Nope, but there are much easier ways :) see my reply...

              Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

              T 1 Reply Last reply
              0
              • H Harvey Saayman

                tasumisra wrote:

                did i stop you to answer

                Nope, but there are much easier ways :) see my reply...

                Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                T Offline
                T Offline
                tasumisra
                wrote on last edited by
                #8

                I have seen your answer ... but some times we can't hardcode any querry from sql command it will cost more if u need to change your condition. anyway if you have ever used WCF then in services we are binding the reader object with our business object for each row that time we can filter it out more easily...

                vikas da

                H 1 Reply Last reply
                0
                • T tasumisra

                  I have seen your answer ... but some times we can't hardcode any querry from sql command it will cost more if u need to change your condition. anyway if you have ever used WCF then in services we are binding the reader object with our business object for each row that time we can filter it out more easily...

                  vikas da

                  H Offline
                  H Offline
                  Harvey Saayman
                  wrote on last edited by
                  #9

                  tasumisra wrote:

                  some times we can't hardcode any querry

                  In that case, create a stored procedure for SQL and call that in your application... problem solved :) OR Use the DataView object, i use this frequently to filter data dynamically

                  Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                  T 1 Reply Last reply
                  0
                  • K kulandaivel_mca2007

                    i am using windows aplliction using c#... i have 1000 records in my table.... which has fields CUSTOMER_ID,NAME,CITY,SALARY..... I HAVE TO SEE ONLY THE CUSTOMER WHO ARE LIVING THE CITY CALLED "DOWNTOWN" HOW CAN I SEE THIS IN DATAGRIDVIEW... PLS REPLY... GIVE ME SUGGESTION OR SAMPLE CODING... THNX IN ADVANCE

                    V Offline
                    V Offline
                    V 0
                    wrote on last edited by
                    #10

                    as mentioned use the filter option or change the query to have a where clause. but FYI. THE USE OF CAPITALS is considered shouting in forums. :-D

                    V.
                    Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

                    1 Reply Last reply
                    0
                    • H Harvey Saayman

                      tasumisra wrote:

                      some times we can't hardcode any querry

                      In that case, create a stored procedure for SQL and call that in your application... problem solved :) OR Use the DataView object, i use this frequently to filter data dynamically

                      Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                      T Offline
                      T Offline
                      tasumisra
                      wrote on last edited by
                      #11

                      Harvey Saayman wrote:

                      In that case, create a stored procedure for SQL and call that in your application... problem solved

                      what if you dont have acess to the stored proc....??? :) its written in COBOL and residing in Mainframe...

                      vikas da

                      H 1 Reply Last reply
                      0
                      • T tasumisra

                        Harvey Saayman wrote:

                        In that case, create a stored procedure for SQL and call that in your application... problem solved

                        what if you dont have acess to the stored proc....??? :) its written in COBOL and residing in Mainframe...

                        vikas da

                        H Offline
                        H Offline
                        Harvey Saayman
                        wrote on last edited by
                        #12

                        tasumisra wrote:

                        COBOL

                        Then you get your ass out of the C# forum :laugh:

                        Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                        T 1 Reply Last reply
                        0
                        • H Harvey Saayman

                          tasumisra wrote:

                          COBOL

                          Then you get your ass out of the C# forum :laugh:

                          Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                          T Offline
                          T Offline
                          tasumisra
                          wrote on last edited by
                          #13

                          do you know ?????? a stored proc can be written in COBOL.. and sorry you can acess these stored proc using your ass..from C# also

                          vikas da

                          H 1 Reply Last reply
                          0
                          • T tasumisra

                            do you know ?????? a stored proc can be written in COBOL.. and sorry you can acess these stored proc using your ass..from C# also

                            vikas da

                            H Offline
                            H Offline
                            Harvey Saayman
                            wrote on last edited by
                            #14

                            Calm d0wn dude, i was JOKING... sheesh

                            Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                            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