I have a form with a recordset which is filtered on some controls on the form. In the code behind page I want to loop through the records as filtered on the form. I can set up another SqlDataSource and refilter it on the same controls, but I'm wondering if there's an easier way just to select the existing recordset as filtered.

You can create a custom class to hold a row of data then create a collection to hold all of the custom objects. Then you can traverse the data in any manner you wish without additional trips to the database (depending on the volume).

how about using sqlcommandbuilder and using dataset and data adapter

using a datarow, you can loop through its row.

Hi folks,
Thanks for the responses. I guess I didn't state the question very well. Thanks to examples on DaniWeb I can loop through a dataset fine. My question is if the form already has a dataset on the designer page (i.e. Form1.aspx), can I access that existing dataset from the code behind page (Form1.aspx.cs)? I'm rebuilding another dataset and looping through that fine, I just thought maybe there's an easier way.

Hey dude
It is not possible to access code behind (.aspx.cs) dataset in front end(.aspx) because dataset is defined in class which inherited from the aspx file
(ie., cs--inherits-->aspx ) you ask like conversely so it is not possible.

if you want
You can declare dataset is aspx file then you can use it in both file(code behind, aspx) or
You declare that globally include to your project then only you can access that in any in that project

This article has been dead for over six months. Start a new discussion instead.