[Last Call] Learn how to a build a cloud-first strategyRegister Now


How To Programmatically Access the DataSet Created by a SQLDataSource

Posted on 2006-06-07
Medium Priority
Last Modified: 2008-01-09
I noticed that when you use a SQLDataSource it will automatically do the sorting  on the GridView for you which is great.  I was  however unable to figure out a way to add an Filtering expression to the SQLDataSource's dataView so that I could filter the returned data without using a SQLDataAdapter ---> dataSet ---> dataView, etc.

Using the SQLDataAdapter solved the filtering problem but then I lost the automatic sorting on the GridView Columns provided by the SQLDataSource so now I'm basically, trying to combine two different methods to cut down on the code I have to write.

If I stick with the SQLDataAdapter I'll have to write code to figure out which column the user clicked on and wants to sort.  Any suggestions on ways to do this?

My preferred solution however is to programatically access the dataSet created by the SQLDataSource and simply filter on that and I would expect all of my problems will be solved.

Does anyone see a problem with this apporach and/or have suggestions on how to go about actually writing the code to accomplish this?

Thanks in Advance (TIA)
Question by:Mariyam

Expert Comment

ID: 16860230
First, I do not know how to access the dataset created by SqlDataSource.

However, you should be able to have automatic sorting abilities in the gridview when using a FilterExpression on a SqlDataSource. (The DataSourceMode of the SqlDataSource must be DataSet)

For example, if I have a GridView bound to SqlDataSource1, I can do this

SqlDataSource1.FilterExpression = "CustomerId > 100";

and the column sorting still works fine.

Author Comment

ID: 16890717

I found the answer here on the Experts-Exchange.

I have dv declared globally and included the following line in the page_load !IsPostBack

            this.dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

I have another question that I'm getting ready to post concerning the best way to get my date values to order properly.  They don't sort correctly when I convert them from actual date values to char(8) values so that they display without the time.

I'll ask the Administrator to close out this questions.  Thanks.

Accepted Solution

Netminder earned 0 total points
ID: 16932455
Closed, 350 points refunded.
Site Admin

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question