I need to bring top 100 records from an existing populated dataset. I am attaching the snippet of my code

any change in stored procedure is not an option. The dataset which has data is dsReportData
Exisiting snippet of code.

    Public Sub BindGrid(ByVal pisRebind As Boolean, ByVal poFetchingOptions As MZKObj.FetchingOptions)
        If pisRebind Then
            Dim dsReportData As DataSet
            Dim l_oINT_SimpleExtracts As INT_SimpleExtracts

            If _mintExtracts_ID > 0 Then
                l_oINT_SimpleExtracts = New INT_SimpleExtracts(_mintExtracts_ID, TEMSSecurity.UserDistrict)
                If Not IsDBNull(l_oINT_SimpleExtracts.ExtractType) AndAlso (l_oINT_SimpleExtracts.ExtractType = "Stored Procedure" Or l_oINT_SimpleExtracts.ExtractType = "Customer Stored Procedure") Then
                    dsReportData = l_oINT_SimpleExtracts.GetExtractViewGridDS(_mintExtracts_ID, "", l_oINT_SimpleExtracts.StoredProcedureName, l_oINT_SimpleExtracts.Parameters, TEMSSecurity.UserDistrict)
                    Dim l_strQuesy As String = GetAdhocQuery(TEMSSecurity.UserDistrict, l_oINT_SimpleExtracts.Query_ID, l_oINT_SimpleExtracts)
                    dsReportData = l_oINT_SimpleExtracts.GetExtractViewGridDS(_mintExtracts_ID, l_strQuesy, "", "", TEMSSecurity.UserDistrict)
                End If
            End If

            Dim l_oDataColumn As DataColumn
            Dim l_oDataGridColumn As MZKGrids.MazikGrid.MZKExtBoundColumn
            For Each l_oDataColumn In dsReportData.Tables(0).Columns
                l_oDataGridColumn = New MZKGrids.MazikGrid.MZKExtBoundColumn
                l_oDataGridColumn.HeaderText = l_oDataColumn.ColumnName
                l_oDataGridColumn.DataField = l_oDataColumn.ColumnName

            dgrReportData.DataSource = dsReportData.Tables(0).DefaultView

--Need to pull 100 rows here


            If dsReportData.Tables(0).DefaultView.Count > 100 Then
                cntScriptManager.EnablePartialRendering = True
            End If
        End If
    End Sub
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

Try using 'Linq'. Using link you can somewhat make a query to a variable sort of like you would in sql.. this way getting the top 100 items of a variable would be easy:

Public Sub Linq21()
    Dim customers = GetCustomerList()

    Dim first3WAOrders = From c In customers, o In c.Orders _
        Where c.Region = "WA" Take 3 _
        Select c.CustomerID, o.OrderID, o.OrderDate

    Console.WriteLine("First 3 orders in WA:")
    For Each ord In first3WAOrders
End Sub

Open in new window

where 'take' is the number of record you want to fetch from the variable.

There are other examples at: http://msdn.microsoft.com/en-us/vstudio/bb688088
codedeveloper1Author Commented:
Thanks for the help. I used the the function that accepts a datatable and count and returns a newly populated data table with rows equal to count.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.