asp.net - filter c# listview using filterexpression and multiple dropdowns -
i trying use filterexpression in code behind filter listview based on selection of 4 dropdowns. following code binds listview , fired onselectedindexchanged each of dropdowns...
using (sqldatasource varlistviewdatasource = new sqldatasource()) { string custstr = custfiltdd.selectedvalue; varlistviewdatasource.id = "varlistviewdatasource"; varlistviewdatasource.connectionstring = configurationmanager.connectionstrings["connectionstring"].connectionstring; varlistviewdatasource.selectcommand = "select retdetails.varid, retdetails.status, retdetails.approvalstatus, job.jobname, customer.custid, customer.custname, retdetails.quoteref, retdetails.retcat, retdetails.approvalref, retdetails.fulldesc, retdetails.jobid, retdetails.description, retdetails.value, concat(contact.contactforename, ' ', contact.contactsurname) name, retstatus.retstatusdesc, retcats.retcatdesc retdetails inner join contact on retdetails.requestor = contact.contactid inner join retstatus on retdetails.status = retstatus.retstatusid inner join retcats on retdetails.retcat = retcats.retcatid inner join job on retdetails.jobid = job.jobid inner join customer on job.custid = customer.custid"; if (custfiltdd.selectedvalue != "") { varlistviewdatasource.filterexpression = "custid = '" + custfiltdd.selectedvalue + "'"; } if (jobfiltdd.selectedvalue != "") { varlistviewdatasource.filterexpression = "jobid = '" + jobfiltdd.selectedvalue + "'"; } if (appfiltdd.selectedvalue != "") { varlistviewdatasource.filterexpression = "approvalstatus = '" + appfiltdd.selectedvalue + "'"; } if (statfiltdd.selectedvalue != "") { varlistviewdatasource.filterexpression = "status = '" + statfiltdd.selectedvalue + "'"; } varlistview.datasource = varlistviewdatasource; varlistview.databind(); }
i'm new , understand i'm way off using 4 separate filterexpressions , grateful pointers.
thanks
Comments
Post a Comment