Datagrid, SQLReader and Paging? Shouldn't this work?

Discussion in 'ASP .Net Datagrid Control' started by Roger, Dec 28, 2004.

  1. Roger

    Roger Guest

    I have some code that uses a SQL Stored procedure to return some rows. I
    would then like to have these rows show up in a datagrid.

    sqlCmd = New SqlClient.SqlCommand("R_GetSiphonDetail", sCon)
    sqlCmd.CommandType = CommandType.StoredProcedure
    rdr = sqlCmd.ExecuteReader(CommandBehavior.Default)
    DataGrid1.DataSource = rdr
    DataGrid1.DataBind()

    This works just fine as long as I don't turn on paging.

    As soon as I check the paging option, then the grid will not show up at all.
    Why?????


    Thanks,

    Rog
     
    Roger, Dec 28, 2004
    #1
    1. Advertising

  2. Hi Roger, using DataReader you wont be able to do pagination 'cause
    DataReader provides forward only read.
    I suggest you use a dataset to bind to your datagrid
    P.S : If this post was usefull to you, please clikc 'Yes' on top of this
    post. Thanks
    Hth...
    R. Thomas


    "Roger" wrote:

    > I have some code that uses a SQL Stored procedure to return some rows. I
    > would then like to have these rows show up in a datagrid.
    >
    > sqlCmd = New SqlClient.SqlCommand("R_GetSiphonDetail", sCon)
    > sqlCmd.CommandType = CommandType.StoredProcedure
    > rdr = sqlCmd.ExecuteReader(CommandBehavior.Default)
    > DataGrid1.DataSource = rdr
    > DataGrid1.DataBind()
    >
    > This works just fine as long as I don't turn on paging.
    >
    > As soon as I check the paging option, then the grid will not show up at all.
    > Why?????
    >
    >
    > Thanks,
    >
    > Rog
    >
    >
    >
     
    R. Thomas, aka Xtreme.Net, Dec 29, 2004
    #2
    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. Rico Alexander
    Replies:
    1
    Views:
    727
    William Ryan
    Oct 14, 2003
  2. =?Utf-8?B?UGF1bA==?=

    shouldn't viewstate work for this?

    =?Utf-8?B?UGF1bA==?=, Jul 19, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    442
    One Handed Man \( OHM - Terry Burns \)
    Jul 19, 2004
  3. wh1974
    Replies:
    0
    Views:
    2,440
    wh1974
    Jan 12, 2005
  4. Red
    Replies:
    1
    Views:
    726
  5. =?Utf-8?B?YzY3NjIyOA==?=

    sqlreader.GetValue(sqlreader.GetOrdinal(columnname ) problem

    =?Utf-8?B?YzY3NjIyOA==?=, Feb 24, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    5,415
    =?Utf-8?B?YzY3NjIyOA==?=
    Feb 24, 2006
Loading...

Share This Page