Displaying data in a datagrid

Discussion in 'ASP .Net' started by =?Utf-8?B?Sm9obg==?=, Feb 10, 2004.

  1. Hi

    What is the best way to populate a datagrid?, can you populate it row by row using a datareader or is dataAdapater.Fill then Dataset binding the only way

    John
    =?Utf-8?B?Sm9obg==?=, Feb 10, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?Sm9obg==?=

    Scott M. Guest

    The data doesn't have to come from a DataAdapter, but calling
    dataGrid.DataBind after setting its dataSource is the only way.


    "John" <> wrote in message
    news:...
    > Hi,
    >
    > What is the best way to populate a datagrid?, can you populate it row by

    row using a datareader or is dataAdapater.Fill then Dataset binding the only
    way?
    >
    > John
    Scott M., Feb 11, 2004
    #2
    1. Advertising

  3. What are the different ways of populating the datagrid, can I do it one row at a time.

    ----- Scott M. wrote: -----

    The data doesn't have to come from a DataAdapter, but calling
    dataGrid.DataBind after setting its dataSource is the only way.


    "John" <> wrote in message
    news:...
    > Hi,
    >> What is the best way to populate a datagrid?, can you populate it row by

    row using a datareader or is dataAdapater.Fill then Dataset binding the only
    way?
    >> John
    =?Utf-8?B?Sm9obg==?=, Feb 11, 2004
    #3
  4. =?Utf-8?B?Sm9obg==?=

    Scott M. Guest

    I answered that question already....When you set the DataGrid.DataSource
    property you are telling the grid where ALL the data is that it will be
    bound to. When you call DataGrid.DataBind, you are instructing the grid to
    bind itself to ALL of the data. You can't do it one record at a time. This
    is the only way to populate a DataGrid.

    If you want that functionality, look into building an HTML table dynamically
    (like the way we did it in classic ASP).


    "John" <> wrote in message
    news:...
    > What are the different ways of populating the datagrid, can I do it one

    row at a time.
    >
    > ----- Scott M. wrote: -----
    >
    > The data doesn't have to come from a DataAdapter, but calling
    > dataGrid.DataBind after setting its dataSource is the only way.
    >
    >
    > "John" <> wrote in message
    > news:...
    > > Hi,
    > >> What is the best way to populate a datagrid?, can you populate it

    row by
    > row using a datareader or is dataAdapater.Fill then Dataset binding

    the only
    > way?
    > >> John

    >
    >
    >
    Scott M., Feb 11, 2004
    #4
  5. =?Utf-8?B?Sm9obg==?=

    ajaymehra Guest

    - you can use a sqlcommand to write a query and retrieve the records i
    a datatable or dataview and bind it to the datagrid

    - you can use the dataadapter method

    I think you are thinking in terms of classic ASP - do while no
    rs.EOF.....rs.MoveNext

    You cant do that here.
    You can however have complete control over the datagrid to display wha
    columns and what rows by setting the Datagrids AutoGenerateColumn
    property to FALSE and using the ItemBound method to display data.

    newsgroup user wrote:
    > *Hi,
    >
    > What is the best way to populate a datagrid?, can you populate it ro
    > by row using a datareader or is dataAdapater.Fill then Datase
    > binding the only way?
    >
    > John


    ajaymehr
    -----------------------------------------------------------------------
    Posted via http://www.mcse.m
    -----------------------------------------------------------------------
    View this thread: http://www.mcse.ms/message380997.htm
    ajaymehra, Feb 11, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vinayak

    Displaying data in datagrid problem

    vinayak, Jul 26, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    553
    Carl Prothman [MVP]
    Jul 28, 2003
  2. Nedu N
    Replies:
    1
    Views:
    424
    Henrik Grotle
    Sep 18, 2003
  3. Nedu N
    Replies:
    2
    Views:
    414
    Mark Schubert
    Nov 19, 2003
  4. Piotr Karwatka

    Displaying tree data like in DataGrid

    Piotr Karwatka, Dec 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    388
    Piotr Karwatka
    Dec 2, 2004
  5. .Net Sports

    datagrid not displaying data table data

    .Net Sports, Aug 30, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,768
    .Net Sports
    Aug 31, 2005
Loading...

Share This Page