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. DataSet columns

DataSet columns

Scheduled Pinned Locked Moved C#
questionannouncement
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
    ziwez0
    wrote on last edited by
    #1

    I have a class that returns a dataset, csServices GetDataServices = new csServices(); gvServices.DataSource = GetDataServices.ServicesDS; gvServices.DataMember = "tbl_Services"; all im doing is reading data, dont need to update etc.. Although my dataset (ServicesDS) returns 1 table and 6 columns, i dont need to show all the columns in my gridview(gvServices), how can I only show the columns I specifiy ie "ID", "Name"? Following on.. should I be ref to a dataset or datatable, pros, cons? thanks

    W M 2 Replies Last reply
    0
    • Z ziwez0

      I have a class that returns a dataset, csServices GetDataServices = new csServices(); gvServices.DataSource = GetDataServices.ServicesDS; gvServices.DataMember = "tbl_Services"; all im doing is reading data, dont need to update etc.. Although my dataset (ServicesDS) returns 1 table and 6 columns, i dont need to show all the columns in my gridview(gvServices), how can I only show the columns I specifiy ie "ID", "Name"? Following on.. should I be ref to a dataset or datatable, pros, cons? thanks

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      You're not telling which GridView you're using, web control, WPF etc? Anyway, most gridviews work in a way that if you don't add columns to it before you bind the data, all columns are added automatically. So you should create the necessary columns beforehand either in code or in designer.

      The need to optimize rises from a bad design.My articles[^]

      Z 1 Reply Last reply
      0
      • W Wendelius

        You're not telling which GridView you're using, web control, WPF etc? Anyway, most gridviews work in a way that if you don't add columns to it before you bind the data, all columns are added automatically. So you should create the necessary columns beforehand either in code or in designer.

        The need to optimize rises from a bad design.My articles[^]

        Z Offline
        Z Offline
        ziwez0
        wrote on last edited by
        #3

        win forms

        W 1 Reply Last reply
        0
        • Z ziwez0

          win forms

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #4

          If you're using DataGridView, then you could use for example DataGridViewColumnCollection.Add Method [^] to add desired column to the DataGridView before you bind the data (or add the columns in designer).

          The need to optimize rises from a bad design.My articles[^]

          1 Reply Last reply
          0
          • Z ziwez0

            I have a class that returns a dataset, csServices GetDataServices = new csServices(); gvServices.DataSource = GetDataServices.ServicesDS; gvServices.DataMember = "tbl_Services"; all im doing is reading data, dont need to update etc.. Although my dataset (ServicesDS) returns 1 table and 6 columns, i dont need to show all the columns in my gridview(gvServices), how can I only show the columns I specifiy ie "ID", "Name"? Following on.. should I be ref to a dataset or datatable, pros, cons? thanks

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            I use 2 methods limit the columns selected from the database, this gets rid of useless columns set the column. visible = false - this hides the columns that are required but do not need to be seen by the user (id column) You can still access the data in a non visible column

            Never underestimate the power of human stupidity RAH

            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