Multiple parameters for a datagrid
I'm a asp.net newbie and still figuring out sql and have a problem that seems simple but the solution is beyond me. I'm working with Visual Web Developer 2005 Express Edition and potentially with our SQL 7.0 server. Right now I'm working with an Access 2003 database. I've been looking through the Professional & Beginning ASP.NET 2.0 books and haven't seen what I need yet (but I've probably just missed it).
I'm trying to build a page with three controls - a dropdownlist, checkboxlist and a datagrid, all populated by a SQL query. The dropdownlist is populated by Facility, the checkboxlist is filled with a field FileSection based on the Facility choice in the dropdownlist and I've built a variable, strFileSection, that is built from an iteration from the selected values of the checkbox list, e.g., 'Value1','Value3','Value5'. When I use the default choice in the Data Source wizard â the â=â operator â I only end up with a datagrid of the first choice.
What I want to do is display a datagrid with documents based on a SQL query with a WHERE statement is (Facility = FacilityChoice) AND (FileSection IN (@strFileSection)). The IN clause does not appear in the data source wizard at all so I type this in the source code like so:
.. WHERE (([Facility] = ?) AND ([FileSection] IN ( ?)) where the second parameter is <asp:QueryStringParameter Name="FileSection" QueryStringField="@strFileSection" Type="String" /> (and I'm not sure I'm using the correct parameter type).
When I run the page, the first two controls work fine but the datagrid does not display, nor are any errors displayed. I've read multiple posts in multiple forums on this problem but haven't seen a clear answer, but many answers include using SQL stored procedures and whatnot. All the examples in Professional ASP.NET 2.0 seem to have WHERE statements there the field = value and the wizard does not include the IN phrase at all. So, is this possible?
|