Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get Item.Count after changing SQL select
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01480686
Message ID:
01480757
Views:
58
>Ok, I got a bit further in my research:
>
>on one of the MS sites it specified that the querry (the command specified in the .SelectCommand property) is automaticly executed by the object which is .DataBound to the SQLDataSource.
>
>This means it happens too late for me - when the server is done and the client has the control.
>
>I also know that I should be able to trigger the querry myself with .Select(). However, it wants a DataSourceSelectArgument - which i have no clue on how to pass that one, given the command is already in the .SelectCommand.
>
>Anyone whant to give it a shot? (I have a feeling there has to be an easier way to do this)

This doesn't directly answer your question, but I tend to avoid the various DataSource controls like the plague for a lot of these reasons. If you work with them exactly the way they expected you to (and don't want to do anything differently), they're fine. As soon as you deviate things get way too complicated. I usually populate the DataSource directly from my own business objects (which have the data access stuff abstracted for me).

For example, my code would usually look more like this (sorry, C#)
var master = new MasterBizObj();
var items =  master.GetAllRecords();
this.Listbox1.DataSource = items;
this.Listbox1.DataTextField = "ResultField";
this.Listbox1.DataValueField = "DocLocation";
this.Listbox1.DataBind();
This way I completely control when the query is run and I have the ability to run different queries if necessary, get other info out of the result (like count), etc.

If you're just hitting SQL Server you might want to look at LINQ to SQL. Yeah, yeah, it's considered a "dead" product but it's really easy to use and works pretty well (Entity Framework 4 is the replacement if you'd rather use it).

(Start at Part 1 - this page just has links to all of the other parts as well)
http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx

If that freaks you out, you could always just write code to make a connection and get the data tables yourself.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform