We help IT Professionals succeed at work.

Grid View filtering

flfmmqp
flfmmqp asked
on
783 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>
Comment
Watch Question

Author

Commented:
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>
ina_donInformation Systems Expert
CERTIFIED EXPERT

Commented:
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.
Information Systems Expert
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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.  
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.