Results 1 to 4 of 4

Thread: datagrid questions

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    151

    datagrid questions

    hi,

    I have some questions about datagrid,

    1)when I have a datagrid, does it mean, it needs to connect with server?

    2)If a user changed some values in the datagrid, how can I update it? (could you please provide some dummy coding?)

    3)After all of the process has done, how could I store the information from datagrid to database?



    Thanks,
    NewBie
    Last edited by VB.NETNEWBIE; Sep 22nd, 2004 at 09:04 AM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: datagrid questions

    1)when I have a datagrid, does it mean, it needs to connect with server?

    Not necesarily. You could create a local dataset or even load an XML file into it.

    2)If a user changed some values in the datagrid, how can I update it? (could you please provide some dummy coding?)

    After you bind a datagrid to a dataset, the changes will be reflected in the dataset.


    3)After all of the process has done, how could I store the information from datagrid to database?

    By .Update()ing the data adapter to save changes to the db. (Assuming you filled the dataset from a dataadapter)

  3. #3
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    and to update the dataadapter you must use commandbuilder

  4. #4
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: datagrid questions

    Originally posted by VB.NETNEWBIE
    hi,

    2)If a user changed some values in the datagrid, how can I update it? (could you please provide some dummy coding?)

    3)After all of the process has done, how could I store the information from datagrid to database?



    Thanks,
    NewBie
    VB Code:
    1. 'ds is a dataset
    2. 'da is dataadapter
    3. 'lets assume you have ds and add a datatable in it.
    4. ds.tables.add(new datatable("dt"))
    5. if ds.haschanges then
    6.     ds.tables("dt").getchanges
    7.     dim cb as new sqlcommandbuilder(da)
    8.     da.update(ds.tables("dt"))
    9. end if

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width