Web Analytics Made Easy -
StatCounter HELP with filtered table results - CodingForum


No announcement yet.

HELP with filtered table results

  • Filter
  • Time
  • Show
Clear All
new posts

  • HELP with filtered table results

    OK I am wanting to build a table that I can enter data in to and have people sort by a drop down box like the 4th table down on this list -- http://www.javascriptkit.com/script/...lefilter.shtml

    But I have followed those instructions step by step and it never works. I was told to use .asp I have changed my page to a .asp and now have no clue where to go from here. In searching this site I have found this code --

    function Filter(table){
    var f=document.getElementById('f').value.toUpperCase();
    for (a=1; a<table.rows.length; a++)
    if (table.rows[a].cells[0].innerHTML.toUpperCase().indexOf(f)!=0)
    table.rows[a].style.display="none"; else

    <table id="states" border=1>
    <tr><td>MARSHALL ISLANDS</td><td>MH</td></tr>

    <input type="text" name="f" id="f">
    <input type="button" value="Filter" onclick="Filter(document.getElementById('states'));">

    But it gives me a filter that I have to type in. I am looking for drop downs that allow me to filter so say you select drop down for fields that contain "A" then another drop down for a field that contains "B" so the results show fields that contain "A" and "B"

    And PS I am semi new to the code world so please don't assume I know some stuff dumb it down a little HAHA

  • #2
    No one?


    • #3
      filter results in gridview

      Refer to this sample:

      <%@ page autoeventwireup="true" codefile="FilterWithDropDownList.aspx.cs"
              inherits="GridView_FilterWithDropDownList" language="C#" masterpagefile="~/MasterPages/Default.master"
              title="GridView: Filter With DropDownList" %>
      <asp:content id="Content1" runat="Server" contentplaceholderid="ContentPlaceHolder1">
              Select Category:
              <asp:dropdownlist id="ddlCategories" runat="server" appenddatabounditems="True" autopostback="True"
                      datasourceid="sdsCategories" datatextfield="CategoryName" datavaluefield="CategoryID">
                      <asp:listitem text="All Categories" value="-1">
              <asp:sqldatasource id="sdsCategories" runat="server" connectionstring="<%$ ConnectionStrings:NorthwindConnectionString %>"
                      selectcommand="SELECT [CategoryID], [CategoryName] FROM [Categories]">
              <asp:gridview id="gvProducts" runat="server" autogeneratecolumns="False" datakeynames="ProductID"
                      datasourceid="sdsProducts" style="margin-top: 12px;">
                              <asp:boundfield datafield="ProductID" headertext="ProductID" insertvisible="False"
                                      readonly="True" sortexpression="ProductID" />
                              <asp:boundfield datafield="ProductName" headertext="ProductName" sortexpression="ProductName" />
                              <asp:boundfield datafield="CategoryName" headertext="CategoryName" sortexpression="CategoryName" />
              <asp:sqldatasource id="sdsProducts" runat="server" connectionstring="<%$ ConnectionStrings:NorthwindConnectionString %>"
                      selectcommand="SELECT [ProductID], [ProductName], [CategoryName] FROM [Alphabetical list of products] WHERE ([CategoryID] = CASE WHEN @CategoryID = -1 THEN [CategoryID] ELSE @CategoryID END) ORDER BY [ProductName]">
                              <asp:controlparameter controlid="ddlCategories" name="CategoryID" propertyname="SelectedValue"
                                      type="Int32" />
      Don't forget to mark solution providing post as "Answered".
      It helps others to find correct solutions!


      • #4
        But gridview doesn't work in classic ASP, and he *DID* post in the classic ASP forum.

        He also seemed to be looking for a JavaScript solution, so he should have posted in the JavaScript forum.
        Be yourself. No one else is as qualified.