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. Update DataGrid

Update DataGrid

Scheduled Pinned Locked Moved C#
databasetutorialannouncement
17 Posts 4 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.
  • M Mazdak

    I kow it,I do it like this: oleDbCommand1.Connection.Open(); oleDbCommand1.ExecuteNonQuery(); oleDbDataAdapter1.Update(dataSet11,"Table2"); dataGrid1.DataSource=dataSet11.Tables["Table2"]; ???Binding???????? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
    Wish You Were Here-Pink Floyd-1975

    J Offline
    J Offline
    James T Johnson
    wrote on last edited by
    #8

    In WinForms I found all I had to do was assign to the DataSource property as you have done; I think in ASP.NET you do that and you have to call dataGrid1.DataBind();. Any closer? James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

    M 1 Reply Last reply
    0
    • J James T Johnson

      In WinForms I found all I had to do was assign to the DataSource property as you have done; I think in ASP.NET you do that and you have to call dataGrid1.DataBind();. Any closer? James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #9

      James T. Johnson wrote: dataGrid1.DataBind();. I'm aware of that in ASP.Net,but it does not exist in windows form:( James T. Johnson wrote: In WinForms I found all I had to do was assign to the DataSource property as you have done; You mean you set the datasource of datagrind without any databinding,and datagrid reflect the changes ?:confused: Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
      Wish You Were Here-Pink Floyd-1975

      J 2 Replies Last reply
      0
      • A Andy Smith

        Mazdak wrote: oleDbCommand1.Connection.Open(); oleDbCommand1.ExecuteNonQuery(); oleDbDataAdapter1.Update(dataSet11,"Table2"); dataGrid1.DataSource=dataSet11.Tables["Table2"]; dataGrid1.DataBind();

        M Offline
        M Offline
        Mazdak
        wrote on last edited by
        #10

        Andy Smith wrote: dataGrid1.DataBind(); That does not exist in WinForms:( Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
        Wish You Were Here-Pink Floyd-1975

        A 1 Reply Last reply
        0
        • M Mazdak

          James T. Johnson wrote: dataGrid1.DataBind();. I'm aware of that in ASP.Net,but it does not exist in windows form:( James T. Johnson wrote: In WinForms I found all I had to do was assign to the DataSource property as you have done; You mean you set the datasource of datagrind without any databinding,and datagrid reflect the changes ?:confused: Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
          Wish You Were Here-Pink Floyd-1975

          J Offline
          J Offline
          James T Johnson
          wrote on last edited by
          #11

          Mazdak wrote: You mean you set the datasource of datagrind without any databinding,and datagrid reflect the changes I'll have to see if i can find my test code; but I don't recall doing anything more than what you have done. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

          1 Reply Last reply
          0
          • M Mazdak

            Andy Smith wrote: dataGrid1.DataBind(); That does not exist in WinForms:( Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
            Wish You Were Here-Pink Floyd-1975

            A Offline
            A Offline
            Andy Smith
            wrote on last edited by
            #12

            oh, oops sorry, i'm a webguy, and I just kind of assumed... um, From my vb6 days... I seem to remember setting the datasource to nothing and then setting it again... so try something like this: dataGrid1.DataSource = null; dataGrid1.DataSource = myDataSourceExpression;

            1 Reply Last reply
            0
            • M Mazdak

              James T. Johnson wrote: dataGrid1.DataBind();. I'm aware of that in ASP.Net,but it does not exist in windows form:( James T. Johnson wrote: In WinForms I found all I had to do was assign to the DataSource property as you have done; You mean you set the datasource of datagrind without any databinding,and datagrid reflect the changes ?:confused: Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
              Wish You Were Here-Pink Floyd-1975

              J Offline
              J Offline
              James T Johnson
              wrote on last edited by
              #13

              I've uploaded a quick sample I did; by all means do not look at it as the proper way to deal with user created dialogs or naming conventions (i stuck with defaults for names, and the dialog is handled oddly since i wanted to require both username/password and didn't look up the "proper" way of doing that). I've included the compiled executable so you don't have to try monkeying around with the VS.NET generated .resx's :) http://www.takklesoft.com/dotnet/DataGridTestApp.zip James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

              M 1 Reply Last reply
              0
              • J James T Johnson

                I've uploaded a quick sample I did; by all means do not look at it as the proper way to deal with user created dialogs or naming conventions (i stuck with defaults for names, and the dialog is handled oddly since i wanted to require both username/password and didn't look up the "proper" way of doing that). I've included the compiled executable so you don't have to try monkeying around with the VS.NET generated .resx's :) http://www.takklesoft.com/dotnet/DataGridTestApp.zip James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                M Offline
                M Offline
                Mazdak
                wrote on last edited by
                #14

                Really thanks James,You are always big help.:rose: Now I can add recoeds to database and show it in DataGrid too but I have a question about it: In Visual C++ when I add a record to a database the DataGrid reflect it by using only Refresh() method,But here in .NET I have to create new Row dynamicly for DataGrid and do it seprately from the new record in DataSource(Here when I say DataSource I mean my Access file not DataSet),Is that right or other way exists too? I think I mess up thinks in VC++ and C# ;) Thanks :) Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
                Wish You Were Here-Pink Floyd-1975

                J 1 Reply Last reply
                0
                • M Mazdak

                  Really thanks James,You are always big help.:rose: Now I can add recoeds to database and show it in DataGrid too but I have a question about it: In Visual C++ when I add a record to a database the DataGrid reflect it by using only Refresh() method,But here in .NET I have to create new Row dynamicly for DataGrid and do it seprately from the new record in DataSource(Here when I say DataSource I mean my Access file not DataSet),Is that right or other way exists too? I think I mess up thinks in VC++ and C# ;) Thanks :) Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
                  Wish You Were Here-Pink Floyd-1975

                  J Offline
                  J Offline
                  James T Johnson
                  wrote on last edited by
                  #15

                  Mazdak wrote: Is that right or other way exists too? I haven't delved too deep into data binding yet, soon as i get the crummy design phase done though I'll be diving into it head first :) But from what I can tell if you update the data source without going through the underlying dataset/table, then you have to go about it as you are now. If you make your changes through the DataSet (and the underlying DataTables) then you can just call Update on the *DataAdapter to have the changes reflected back to the data source. Mazdak wrote: Really thanks James,You are always big help. :rose: Awwwww shucks :-O :laugh: James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                  M 1 Reply Last reply
                  0
                  • J James T Johnson

                    Mazdak wrote: Is that right or other way exists too? I haven't delved too deep into data binding yet, soon as i get the crummy design phase done though I'll be diving into it head first :) But from what I can tell if you update the data source without going through the underlying dataset/table, then you have to go about it as you are now. If you make your changes through the DataSet (and the underlying DataTables) then you can just call Update on the *DataAdapter to have the changes reflected back to the data source. Mazdak wrote: Really thanks James,You are always big help. :rose: Awwwww shucks :-O :laugh: James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                    M Offline
                    M Offline
                    Mazdak
                    wrote on last edited by
                    #16

                    Here you talk in simple words,I understand them. ;) Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
                    Wish You Were Here-Pink Floyd-1975

                    J 1 Reply Last reply
                    0
                    • M Mazdak

                      Here you talk in simple words,I understand them. ;) Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
                      Wish You Were Here-Pink Floyd-1975

                      J Offline
                      J Offline
                      James T Johnson
                      wrote on last edited by
                      #17

                      My intention is never to confuse anyone, but at times it sounds like English isn't my native language :( I have no idea why that is, I know the rules for grammar structure and what not but my thoughts always come out jumbled around so i have to try to piece them together the correct way. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                      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