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. binding individual columns of a datgrid to a dataset/datatable

binding individual columns of a datgrid to a dataset/datatable

Scheduled Pinned Locked Moved C#
wpfwcf
7 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
    Keshav V Kamat 0
    wrote on last edited by
    #1

    hello all, could some one tell me how could i bind the individual columns, already created to a dataset or a datatable during runtime. thanks in advance.

    Keshav Kamat :) India

    J 1 Reply Last reply
    0
    • K Keshav V Kamat 0

      hello all, could some one tell me how could i bind the individual columns, already created to a dataset or a datatable during runtime. thanks in advance.

      Keshav Kamat :) India

      J Offline
      J Offline
      joon vh
      wrote on last edited by
      #2

      could you give us an example of what you're trying to achieve? because binding different columns to different datasources doesn't make much sense to me. Might just be me though ;) Please clarify.


      public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

      K 1 Reply Last reply
      0
      • J joon vh

        could you give us an example of what you're trying to achieve? because binding different columns to different datasources doesn't make much sense to me. Might just be me though ;) Please clarify.


        public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

        K Offline
        K Offline
        Keshav V Kamat 0
        wrote on last edited by
        #3

        ya sure. well here is my case. i have a database, which has several columns. I need to modify the contents of a single column. Looking at a different side, binding a single column to a separate data source doesnt make sense to me either. what I really want is to modify the contents of a cell of a column of a datagrid. Can i do it using a datatable or a dataset, coz it is much faster, than accessing a datagrid as Datagrid1.Rows[i].Cells[j]. m trying to modify a cell. how to do it, if i bind a datagrid to a datatable.

        Keshav Kamat :) India

        J 1 Reply Last reply
        0
        • K Keshav V Kamat 0

          ya sure. well here is my case. i have a database, which has several columns. I need to modify the contents of a single column. Looking at a different side, binding a single column to a separate data source doesnt make sense to me either. what I really want is to modify the contents of a cell of a column of a datagrid. Can i do it using a datatable or a dataset, coz it is much faster, than accessing a datagrid as Datagrid1.Rows[i].Cells[j]. m trying to modify a cell. how to do it, if i bind a datagrid to a datatable.

          Keshav Kamat :) India

          J Offline
          J Offline
          joon vh
          wrote on last edited by
          #4

          You can edit individual cells in DataTables in the same way as you edit cells in a DataGridView. You can (or have to) use DataTable.Rows[i].Cells[j]...


          public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

          K 1 Reply Last reply
          0
          • J joon vh

            You can edit individual cells in DataTables in the same way as you edit cells in a DataGridView. You can (or have to) use DataTable.Rows[i].Cells[j]...


            public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }

            K Offline
            K Offline
            Keshav V Kamat 0
            wrote on last edited by
            #5

            well ok. as u said in the previous replies, when i try to bind a datagrid to a data table and try to access the cell or the row count of the data table, it says object reference not set. it comes null. here is how i try to bind a datagrid to a datatable. DataTable dt1=new DataTable("dt1"); dt1 = (DataTable)LoggerDatagrid.DataSource; please tell me, if I am making a mistake anywhere. thanks in advance.

            Keshav Kamat :) India

            P J 2 Replies Last reply
            0
            • K Keshav V Kamat 0

              well ok. as u said in the previous replies, when i try to bind a datagrid to a data table and try to access the cell or the row count of the data table, it says object reference not set. it comes null. here is how i try to bind a datagrid to a datatable. DataTable dt1=new DataTable("dt1"); dt1 = (DataTable)LoggerDatagrid.DataSource; please tell me, if I am making a mistake anywhere. thanks in advance.

              Keshav Kamat :) India

              P Offline
              P Offline
              Pualee
              wrote on last edited by
              #6

              I have not read the whole thread, but what comes to mind first is, have you looked in the following: http://www.codeproject.com/books/PresentDataDataGridView.asp[^] I found that little gem yesterday trying to solves some other issues. Pualee

              1 Reply Last reply
              0
              • K Keshav V Kamat 0

                well ok. as u said in the previous replies, when i try to bind a datagrid to a data table and try to access the cell or the row count of the data table, it says object reference not set. it comes null. here is how i try to bind a datagrid to a datatable. DataTable dt1=new DataTable("dt1"); dt1 = (DataTable)LoggerDatagrid.DataSource; please tell me, if I am making a mistake anywhere. thanks in advance.

                Keshav Kamat :) India

                J Offline
                J Offline
                joon vh
                wrote on last edited by
                #7

                You're doing it the wrong way around. It should be : LoggerDatagrid.DataSource = dt1; now your datagrid should be populated, and then you can start looking for cells to edit.


                Visual Studio can't evaluate this, can you? public object moo { __get { return moo; } __set { moo = value; } }

                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