4 Replies - 211 Views - Last Post: 23 March 2019 - 01:15 PM Rate Topic: -----

#1 darthvader45   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 21-February 13

Filtering A DataList by SelectedValue in DropDownList

Posted 23 March 2019 - 09:50 AM

I have been searching for a solution to this, and found something that might help, but now I'm stumped. It involves a FilterExpression and FilterParameters. I have made my SELECT statement as well as the aforementioned filter code, but I am struggling to make it work, as I keep getting a Cannot Find Column error.

Here's my select statement, filterexpression and filterparameters for the sqldatasource named SqlDataSource2:
SelectCommand="SELECT Incidents.Title, Technicians.Name, Incidents.Description, Incidents.DateOpened, Incidents.DateClosed FROM Incidents INNER JOIN Technicians ON Incidents.TechID = Technicians.TechID INNER JOIN Products ON Incidents.ProductCode = Products.ProductCode INNER JOIN Customers ON Incidents.CustomerID = Customers.CustomerID" FilterExpression="CustomerID= '{000}'"><FilterParameters><asp:ControlParameter Name="Tab" ControlID="ddlCustomers" 
PropertyName="SelectedValue"/></FilterParameters>


Is This A Good Question/Topic? 0
  • +

Replies To: Filtering A DataList by SelectedValue in DropDownList

#2 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 209
  • View blog
  • Posts: 1,187
  • Joined: 05-December 13

Re: Filtering A DataList by SelectedValue in DropDownList

Posted 23 March 2019 - 10:17 AM

Is this where we do guessing games?

Which column? What thus the error actually say? Did you do a stack trace to be sure? If so post the output.

This happens when the cell it is looking to get a value from does not exist or when the cell returns null. Double check your case sensitivity.
Was This Post Helpful? 0
  • +
  • -

#3 darthvader45   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 21-February 13

Re: Filtering A DataList by SelectedValue in DropDownList

Posted 23 March 2019 - 10:22 AM

It is for the CustomerID Column as it says in the error: "Cannot find column [CustomerID]". I have looked through all of the tables and the one I use to display the data, the Incidents table, has a CustomerID field.

Stack trace:
[EvaluateException: Cannot find column [CustomerID].]
   System.Data.NameNode.Bind(DataTable table, List`1 list) +2161609
   System.Data.BinaryNode.Bind(DataTable table, List`1 list) +34
   System.Data.DataExpression.Bind(DataTable table) +84
   System.Data.DataExpression..ctor(DataTable table, String expression, Type type) +162
   System.Data.DataView.set_RowFilter(String value) +141
   System.Web.UI.WebControls.FilteredDataSetHelper.CreateFilteredDataView(DataTable table, String sortExpression, String filterExpression, IDictionary filterParameters) +403
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1830
   System.Web.UI.WebControls.BaseDataList.GetData() +58
   System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +294
   System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +64
   System.Web.UI.WebControls.BaseDataList.DataBind() +81
   System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +62
   System.Web.UI.WebControls.BaseDataList.CreateChildControls() +69
   System.Web.UI.Control.EnsureChildControls() +92
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +883



Was This Post Helpful? 0
  • +
  • -

#4 darthvader45   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 21-February 13

Re: Filtering A DataList by SelectedValue in DropDownList

Posted 23 March 2019 - 11:11 AM

As for the intended function, SqlDataSource2 was intended to join data from three tables (Incidents, Technicians and Products) and filter them based on the selection in a DropDownList (ddlCustomers)which itself is bound to a sqldatasource called SqlDataSource1 (this one retrieving the CustomerID and Name from a table called Customers and sorting them by the Name field).
Was This Post Helpful? 0
  • +
  • -

#5 darthvader45   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 21-February 13

Re: Filtering A DataList by SelectedValue in DropDownList

Posted 23 March 2019 - 01:15 PM

Well, after looking some more, I found the answer to my question: I replaced the FilterExpression and FilterParameter with a SelectParameter that relied on the DropDownList's SelectedValue property. As I went through debugging it, it worked as I expected. Now to polish up the table inside the DataList's ItemTemplate to look professional and it should be ready. In case you want to know about the DataList, it's going to use an HTML table inside of an ItemTemplate. The table will have two rows, the second of which spans all four columns (I used the colspan attribute for this).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1