Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ppl

I am creating a filtered listview, while it is filtering just fine I would like to have a show all option, just don't know what to make the value I was trying to use IS NOT NULL and didn't work

Below is my code for the listbox and data connection

Any hel will be greatly appriciated

<asp:ListBox ID="PayD" runat="server" AutoPostBack="True" 
                            DataSourceID="SqlDataSource2" DataTextField="Payment" DataValueField="Payment" AppendDataBoundItems="true">
                            

<asp:ListItem Value="  ???????   " Selected=True>All
                            
                           
                        

      <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:Raw_dataConnectionString %>" 
 SelectCommand="SELECT * FROM [MiscBilling] WHERE ([Payment] = @Payment)">
                            <SelectParameters>           ^Value from Listbox^
                                <asp:ControlParameter ControlID="PayD" Name="Payment" 
                                    PropertyName="SelectedValue" Type="String" />
                            </SelectParameters>
Posted
Comments
Sandeep Mewara 30-Apr-12 6:11am    
Not clear.
Member 8834082 30-Apr-12 6:28am    
Hi Sandeep

I am looking for a value to give the list item (Value=" ??????? "), that will select all the records in the db WHERE ([Payment] = @Payment)--- @Payment would be the value from the listbox

tx
Sandeep Mewara 30-Apr-12 6:39am    
What's wrong with Select * FROM [MiscBilling] only? Why where clause when you want all the records? :confused:
Member 8834082 30-Apr-12 6:56am    
This is the code as generated in visual studio 2010, I added the

<asp:ListItem Value=" ??????? " Selected=True>All

I have a listbox with fields

all
monthly -Databound
once-off -Databound

This filters the data in my listview according to the user input, I am trying to get the ALL value to show all records in the listview but i need to give it a value in the listbox (this is the value i'm looking for), the data source has a where cluase and this uses the values from the listbox, I tried giving, 'ALL' a value of "is not null" or "> '0'" to make the select where payment is not null to give me all values but it doesn't give me any results, selecting monthly or once-off works, but want to have a option to view all records - monthly and once off while keeping it dynamic if there is another catagory added

Thanks for the help

1 solution

Ok.

Try using wild card character %, something like WHERE Payment LIKE %@Payment%

Generally this is good for strings search. See if this fits in for you.
 
Share this answer
 
Comments
Member 8834082 30-Apr-12 7:28am    
I tried using LIKe % as a value for the listbox but also doen't work, the problem is I cannot make any changes to the actual where cluase in the data connection becuase then it will only show all the records and not filter anymore, it has to be a value given to the list item, in the listbox
Sandeep Mewara 30-Apr-12 7:59am    
If you cannot change the query then it would be difficult. Further, what are the possible values of Payment?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900