sql - Multiple textbox search on a datagrid -


okay struggling head around follow example. (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.filterexpression.aspx)

aim: have 2 dropdowns/textboxes used edit datagrid filtering.

i have tried adding ,firstname='{1}'" ,firstname='{0}'" after =title not seeming work. added control parameter of course firstname.

the below code first version , original.

my code

    <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">         <html xmlns="http://www.w3.org/1999/xhtml" >             <head runat="server">             <title>asp.net example</title>         </head>         <body>                 <form id="form1" runat="server">                      <p>show employees following title:                     <asp:dropdownlist                         id="dropdownlist1"                         runat="server"                         autopostback="true">                         <asp:listitem selected="true">a</asp:listitem>                         <asp:listitem>b</asp:listitem>                         <asp:listitem>c</asp:listitem>                     </asp:dropdownlist></p>   <asp:dropdownlist                         id="dropdownlist2"                         runat="server"                         autopostback="true">                         <asp:listitem selected="true">x</asp:listitem>                         <asp:listitem>y</asp:listitem>                         <asp:listitem>z</asp:listitem>                     </asp:dropdownlist></p>                      <asp:sqldatasource                         id="sqldatasource1"                         runat="server"                         connectionstring="<%$ connectionstrings:mynorthwind%>"                         selectcommand="select employeeid,firstname,lastname,title employees"                         filterexpression="title='{0}' or "firstname='{1}'">                         <filterparameters>                             <asp:controlparameter name="title" controlid="dropdownlist1" propertyname="selectedvalue"/>  <asp:controlparameter name="firstname" controlid="dropdownlist1" propertyname="selectedvalue"/>                         </filterparameters>                     </asp:sqldatasource>                      <p><asp:gridview                         id="gridview1"                         runat="server"                         datasourceid="sqldatasource1"                         autogeneratecolumns="false">                         <columns>                             <asp:boundfield visible="false" datafield="employeeid" />                             <asp:boundfield headertext="first name" datafield="firstname" />                             <asp:boundfield headertext="last name" datafield="lastname" />                         </columns>                     </asp:gridview></p>                  </form>             </body>         </html> 

i had comma seperating search queries. needed put 'or'.

see full code on original post (edited correct) , sample code below..

 <asp:sqldatasource                         id="sqldatasource1"                         runat="server"                         connectionstring="<%$ connectionstrings:mynorthwind%>"                         selectcommand="select employeeid,firstname,lastname,title employees"                         filterexpression="title='{0}' or "firstname='{1}'"> 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -