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

x
?
Solved

Grid View filtering

Posted on 2007-10-01
4
Medium Priority
?
768 Views
Last Modified: 2013-11-26
I am getting closer to figuring out how to filter with the dropdownlist and the Data grid but I am still not gettting it.  Currently I can only filter on dropdown list (ddlDivStatus).  The others do not work so I can't get to the mulitple dropdown filtering that I want to use.  Also on the load I have an "ALL" value which when selected I would like all records to show.  Please help me with this.  I have been searching endlessly for a solution.


<asp:sqldatasource runat="server" id="MySource"
   connectionstring="<%$ ConnectionStrings:CompEvents_DSNConnection %>" ProviderName="<%$ ConnectionStrings:CompEvents_DSNConnection.ProviderName %>"
   SelectCommand="SELECT * FROM [Events]"
   filterexpression="DivStatus='{0}*'"
   >
    <SelectParameters>
     </SelectParameters>
    <filterparameters>
        <asp:ControlParameter ControlID="ddlDivStatus" DefaultValue="*" Name="DivStatus"
            PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlDMA" DefaultValue="*" Name="dma" PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlDivision" DefaultValue="*" Name="Division" PropertyName="SelectedValue" />
   </filterparameters>
</asp:sqldatasource>
0
Comment
Question by:flfmmqp
  • 2
  • 2
4 Comments
 

Author Comment

by:flfmmqp
ID: 19992532
Update:

It seems to be only working with on Filter Parameter at a time.  So if I use this "filterexpression="DivStatus='{0}*'" and I have the control parameter first then it works but if I just change it to the below then DivStatus does not work.  What is missing?  Augh!  I'm losing the little hair I have left.

<filterparameters>
         <asp:ControlParameter ControlID="ddlDMA" DefaultValue="*" Name="dma" PropertyName="SelectedValue" />       <asp:ControlParameter ControlID="ddlDivStatus" DefaultValue="*" Name="DivStatus"
            PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlDivision" DefaultValue="*" Name="Division" PropertyName="SelectedValue" />
   </filterparameters>
0
 
LVL 5

Expert Comment

by:ina_don
ID: 19996533
The reason why its not working is that you have put  filterexpression="DivStatus='{0}*' and then added the three parameters. All that is doing is telling it to use only the first parameter. Try

<asp:sqldatasource runat="server" id="MySource"
   connectionstring="<%$ ConnectionStrings:CompEvents_DSNConnection %>" ProviderName="<%$ ConnectionStrings:CompEvents_DSNConnection.ProviderName %>"
   SelectCommand="SELECT * FROM [Events]"
   filterexpression="ddlDMA = '{0}' AND DivStatus = '{1}' AND ddlDivision = '{2}'"
   >
    <SelectParameters>
     </SelectParameters>
    <filterparameters>
        <asp:ControlParameter ControlID="ddlDivStatus" DefaultValue="*" Name="DivStatus"
            PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlDMA" DefaultValue="*" Name="dma" PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlDivision" DefaultValue="*" Name="Division" PropertyName="SelectedValue" />
   </filterparameters>
</asp:sqldatasource>


That should work.
0
 
LVL 5

Accepted Solution

by:
ina_don earned 2000 total points
ID: 19996543
Sorry copied your solution so the filter expression should be changed to be in line with the parameters or the parameters should be swapped around to suit the expression. i.e. in the last post you had ddlDMA as your first parameter which is what my filter expression caters for.

Enjoy.
0
 

Author Comment

by:flfmmqp
ID: 19997880
Augh Son of a $%*&.  So the 0, 1 and 2 mean which filter parameter!  Thanks for your help.  You have no idea how I struggled on this simple thing.  I thought the 0, 1,  and 2 meant which record in the dropdown was the default selected record.  
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses

864 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