c# - mutiple search textboxes in asp.net -


i have multiple text-boxes , 1 drop-down list in system , i'm using query builder select data multiple tables in database (sql server), , display them in grid view

suggestion id : (textbox) staff id: (textbox) status: (drop down list) staff name: (textbox)

..............................

i want searching result work entering 1 field or multiple fields. problem is, when browse in internet test if queries worked or not, find works entering fields.

this query generated in query builder (visual studio 2010)

select suggestiondetail.suggestiondescription, suggestiondetail.suggestionid, suggestiondetail.dateofsubmission, employee.employeeid, employee.city, employee.employeename, category.categoryname, suggestionstatusdetail.dateoflastupdate, suggestionstatus.statusname  employee  inner join suggestiondetail  on employee.employeeid = suggestiondetail.employeeid  inner join category  on suggestiondetail.categoryid = category.categoryid  inner join suggestionstatusdetail  on suggestiondetail.suggestionid = suggestionstatusdetail.suggestionid  inner join suggestionstatus  on suggestionstatusdetail.statusid = suggestionstatus.statusid  (employee.employeename n'%' + @empname + n'%') or (employee.employeeid '%' + @empid + '%') or (suggestiondetail.suggestionid '%' + @txtdocid + '%') or (suggestionstatus.statusname n'%' + @statusname + n'%') 

and code generated inside html :

     <asp:gridview id="gridview1" runat="server" backcolor="white" class="gridview"          bordercolor="#dedfde" borderstyle="none" borderwidth="1px" cellpadding="4"           enablemodelvalidation="true" forecolor="black" gridlines="vertical"           autogeneratecolumns="false"           datasourceid="sqldatasource2">          <alternatingrowstyle backcolor="white" />          <columns>              <asp:boundfield datafield="suggestiondescription" headertext="suggestiondescription"                   sortexpression="suggestiondescription" />              <asp:boundfield datafield="suugestionid" headertext="suggestionid"                   insertvisible="false" readonly="true" sortexpression="suggestionid" />              <asp:boundfield datafield="dateofsubmission" headertext="dateofsubmission"                   sortexpression="dateofsubmission" />              <asp:boundfield datafield="employeeid" headertext="employeeid"                   sortexpression="employeeid" />              <asp:boundfield datafield="city" headertext="city" sortexpression="city" />              <asp:boundfield datafield="employeename" headertext="employeename"                   sortexpression="employeename" />              <asp:boundfield datafield="categoryname" headertext="categoryname"                   sortexpression="categoryname" />              <asp:boundfield datafield="dateoflastupdate" headertext="dateoflastupdate"                   sortexpression="dateoflastupdate" />              <asp:boundfield datafield="statusname" headertext="statusname"                   sortexpression="statusname" />          </columns> 

any please, still new in visual studio.

     <asp:sqldatasource id="sqldatasource2" runat="server"           connectionstring="<%$ connectionstrings:connectionstring %>"            selectcommand="select suggestiondetail.suggestiondescription, suggestiondetail.suggestionid, suggestiondetail.dateofsubmission, employee.employeeid, employee.city, employee.employeename, category.categoryname, suggestionstatusdetail.dateoflastupdate, suggestionstatus.statusname employee inner join suggestiondetail on employee.employeeid = suggestiondetail.employeeid inner join category on suggestiondetail.categoryid = category.categoryid inner join suggestionstatusdetail on suggestiondetail.suggestionid = suggestionstatusdetail.suggestionid inner join suggestionstatus on suggestionstatusdetail.statusid = suggestionstatus.statusid (employee.employeename n'%' + @empname + n'%') or (employee.employeeid '%' + @empid + '%') or (suggestiondetail.suggestionid '%' + @txtdocid + '%') or (suggestionstatus.statusname n'%' + @statusname + n'%')">          <selectparameters>              <asp:controlparameter controlid="txtstaffname" name="empname"                   propertyname="text" />              <asp:controlparameter controlid="txtstaffid" name="empid" propertyname="text" />              <asp:controlparameter controlid="txtdocid" name="txtdocid"                   propertyname="text" />              <asp:controlparameter controlid="ddstatus" name="statusname"                   propertyname="selectedvalue" />          </selectparameters>      </asp:sqldatasource> 

if joins , other things working fine see had change fields in clause. gives whole result when parameters null/blank(like nullable) , returns filtered result according 1 parameter null/blank.

create/alter storedprocedure sp_name @empname varchar(50) = null, @empid int = null, @txtdocid  int = null, @statusname varchar(50) = null begine     select     suggestiondetail.suggestiondescription, suggestiondetail.suggestionid,     suggestiondetail.dateofsubmission, employee.employeeid, employee.city,     employee.employeename, category.categoryname, suggestionstatusdetail.dateoflastupdate,     suggestionstatus.statusname          employee      inner join     suggestiondetail      on     employee.employeeid = suggestiondetail.employeeid      inner join     category      on     suggestiondetail.categoryid = category.categoryid      inner join     suggestionstatusdetail      on     suggestiondetail.suggestionid = suggestionstatusdetail.suggestionid      inner join     suggestionstatus      on     suggestionstatusdetail.statusid = suggestionstatus.statusid          (employee.employeename n'%' + @empname + n'%' or @empname null)     or     (employee.employeeid '%' + @empid + '%' or @empid null)     or     (suggestiondetail.suggestionid '%' + @txtdocid + '%' or @txtdocid null)     or     (suggestionstatus.statusname n'%' + @statusname + n'%' or @statusname null) end 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -