Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[5292] DataGrid/GridView Paging and Sorting Using A DataReader

Last post 07-12-2007 3:14 PM by inadler. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    • Post Points: 45
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 04-23-2006 9:21 AM In reply to

    Re: [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    Hello

    The DataReaders read one-way data As I undesrtand you dynamically bind your Oracle Database to your Datagird. Try to convert oracleDataReader  to DataView. DataViews can be red 2 way and they are Compatible with AllowPaging=true

    I have recently sent a Control to Asp.Net I think it is in the proccessing stage that Control converts OdbcDataReader to DataView below is the open code for you to give you an idea. You must apply the same logic to your Oracle Reader

    Good Luck,

    Baris ERGUN

    www.thecoreopsis.com

    public static DataView ConvertToDataView(OdbcDataReader setToCheck, string tableName)

    {

    DataTable dataReaderTable = new DataTable(tableName);

    try

    {

    for(int h=0;h<setToCheck.FieldCount;h++)

    {

    DataColumn temp = new DataColumn(setToCheck.GetName(h),setToCheck.GetFieldType(h));

    dataReaderTable.Columns.Add(temp);

    }

    while(setToCheck.Read())

    {

    DataRow dr = dataReaderTable.NewRow();

    for(int g=0;g<setToCheck.FieldCount;g++)

    {

    drGift [G] = setToCheck.GetValue(setToCheck.GetOrdinal(setToCheck.GetName(g)));

    }

    dataReaderTable.Rows.Add(dr);

    }

    return dataReaderTable.DefaultView;

    }

    catch

    {

    return null;

    }

    }

    • Post Points: 5
  • 04-28-2006 5:48 PM In reply to

    • joshhh
    • Not Ranked
    • Joined on 03-16-2006
    • Mexico
    • New Member
    • Points 5

    Re: [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    Sup everyone...

    I have a datagrid and I want to implement a button that will simulate the datagrid scroll down click button. What events do I need to handle? How to make my datagrid rows to scroll once my button is pressed?

     

    • Post Points: 5
  • 05-30-2006 11:30 AM In reply to

    • rendian
    • Not Ranked
    • Joined on 04-18-2006
    • Indonesia
    • New Member
    • Points 5

    Re: [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    Hello...

    Can anybody plis post the C# version?

    Thx in advance...

    • Post Points: 5
  • 07-17-2006 12:24 AM In reply to

    Re: [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    Good article overall.  But the Gridview version cannot work.  One problem is it shows the following property:

    AllowCustomPaging="False"

    that is not available in Gridview.



     

     

    • Post Points: 10
  • 07-18-2006 4:02 PM In reply to

    • DMarko1
    • Top 500 Contributor
    • Joined on 09-19-2003
    • Addicted Member
    • Points 45

    Re: [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    Yeah thanks. No, it does absolutely work, regardless, and even though the "AllowCustomPaging" property isn't part of the Gridview, it does not affect it, as I just copied the code from the article and it ran perfectly. The Gridview simply ignores it, whether set to "True" or "False"

    I would check and make sure it's not something else you may have modified.

    Hope this helps

    • Post Points: 5
  • 08-28-2006 6:57 PM In reply to

    • cc.shine
    • Not Ranked
    • Joined on 08-28-2006
    • New Member
    • Points 10

    Re: [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    I've been searching around, but haven't been able to figure out how to access the individual values.  For example, how would I determine CompanyName for a particular row?
    • Post Points: 5
  • 10-25-2006 9:37 PM In reply to

    • cc.shine
    • Not Ranked
    • Joined on 08-28-2006
    • New Member
    • Points 10

    Re: [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    I'm working on an app that implements a structure and stores a recordset in an ArrayList based upon the example outlined here.  I used the same to bind to a DataGrid and it worked out so well, I thought it might be a better solution that moving back and forth through a DataSet to perform some simple though numerous calculations. 

    In order to perform these calcs, I have to compare elements of the array checking for duplicates on some columns and then just comparing other elements to strings utilizing IndexOf and LastIndexOf.  Unfortunately I haven't been able to get it to work.  On another site I read that those 2 methods use Object.Equals and as the array contains structure objects, I need to override the Equals function.  That route has been just as unsuccessful. 

    The code below generates an that the index is out of range on the line that assigns the array item to 'last' because the LastIndexOf search returns -1.  Thing is the stored procedure I use to retrieve the recordset guarantees that there would be a match on first.account.  Can anyone point me in the right direction?

    Public Overrides Function Equals(ByVal obj As Object) As Boolean

    If obj Is Nothing Or Not Me.GetType() Is obj.GetType() Then

    Return False

    End If

    Dim d As duplicates = CType(obj, duplicates)

    Return Me.account = d.account

    End Function

     

    'Errant code below

    conn.Open()

    Dim reader As SqlDataReader = cmd.ExecuteReader()

    If reader.HasRows Then

    'Create array to hold entries for accounts tracked more than once per LOB

    Dim arrResults As New ArrayList

    Dim dupEntries As New duplicates

    While reader.Read

    With arrResults

    .Add(

    New duplicates(reader.GetValue(0), reader.GetValue(1), reader.GetValue(2), _

    reader.GetValue(3), reader.GetValue(4), reader.GetValue(5), reader.GetValue(6), _

    reader.GetValue(7), reader.GetValue(8), reader.GetValue(9), reader.GetValue(10), _

    reader.GetValue(11), reader.GetValue(12), reader.GetValue(13), reader.GetValue(14)))

    End With

    End While

    reader.Close()

    Dim first As duplicates

    Dim last As duplicates

    Dim i As Integer

    For i = 0 To arrResults.Count - 1

    first =

    CType(arrResults.Item(i), duplicates)

    Trace.Warn(arrResults.LastIndexOf(first.account))

    last = arrResults.Item(arrResults.LastIndexOf(first.account))

    Trace.Warn(

    "first date" & first.tDate)

    Trace.Warn(

    "last date " & last.tDate)

    Next

    End If

     

    • Post Points: 5
  • 11-03-2006 9:29 AM In reply to

    • Martijn
    • Not Ranked
    • Joined on 11-03-2006
    • Netherlands
    • New Member
    • Points 20

    Re: [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    Dimitrios thanks for the informative article. I have picked your code apart and tried out a few variants of your sample code which I am looking to implement into some of my web apps.

    I tried a code sample in a web page that used “Data Grid Paging Using a Data Reader Bound Array List” – no caching or dynamic sorting.

    This method still reads all the data even though a small fraction is only displayed on the page. This works well but when I blew the table up to 100,000 records (I was using MS Access in this experiment) it slowed down somewhat. Admittedly it was substantially faster than a similar sample of code using a dataset on the same database (as expected).

     

    My question is;

     

    Is there any way that straight forward data reader + data grid paging can be implemented in such a way that it will only get the records from the database that the webapp actually displays on the page? Any suggestions, directions or web links would be appreciated.

     

    • Post Points: 5
  • 11-25-2006 8:23 AM In reply to

    Re: [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    this site is really very good. i  m really a big fan of this site thanks to all

    developerfusion team

     

    jitendra negi

     

    • Post Points: 5
  • 07-12-2007 3:14 PM In reply to

    • inadler
    • Not Ranked
    • Joined on 07-12-2007
    • Israel
    • New Member
    • Points 5

    Re: [5292] DataGrid/GridView Paging and Sorting Using A DataReader

    Hi all,

    What about displaying, sorting etc' data in a DataGird/GridView with a paging mechanism using a scrollbar (not a Next/Previous buttons)??

    It seems like no one has ever mention this issue.

    Can anyone please help me solve this problem.

    Regards ido









    • Post Points: 5
Page 1 of 1 (11 items)