Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. SharePoint
  4. Cascading Dropdownlist

Cascading Dropdownlist

Scheduled Pinned Locked Moved SharePoint
sharepointdatabasequestion
4 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James Cash
    wrote on last edited by
    #1

    Hi there. Have two SP lists and ddl-s filled with items from this lists. Need to build dependant ddl-s (smth like country/city) using CAML query. Any ideas?

    D 1 Reply Last reply
    0
    • J James Cash

      Hi there. Have two SP lists and ddl-s filled with items from this lists. Need to build dependant ddl-s (smth like country/city) using CAML query. Any ideas?

      D Offline
      D Offline
      DanielBrownAU
      wrote on last edited by
      #2

      Check out SPServices, in perticular SPCascadeDropdowns. It does use jQuery. A reasonable article here on codeproject is at Two Level Cascading Drop Down in SharePoint 2013 using SPServices[^] Homepage is at jQuery Library for SharePoint Web Services - Home[^] Documentation is at jQuery Library for SharePoint Web Services - Documentation[^] Hope this helps!

      J 2 Replies Last reply
      0
      • D DanielBrownAU

        Check out SPServices, in perticular SPCascadeDropdowns. It does use jQuery. A reasonable article here on codeproject is at Two Level Cascading Drop Down in SharePoint 2013 using SPServices[^] Homepage is at jQuery Library for SharePoint Web Services - Home[^] Documentation is at jQuery Library for SharePoint Web Services - Documentation[^] Hope this helps!

        J Offline
        J Offline
        James Cash
        wrote on last edited by
        #3

        I'll try, thanks a lot!

        1 Reply Last reply
        0
        • D DanielBrownAU

          Check out SPServices, in perticular SPCascadeDropdowns. It does use jQuery. A reasonable article here on codeproject is at Two Level Cascading Drop Down in SharePoint 2013 using SPServices[^] Homepage is at jQuery Library for SharePoint Web Services - Home[^] Documentation is at jQuery Library for SharePoint Web Services - Documentation[^] Hope this helps!

          J Offline
          J Offline
          James Cash
          wrote on last edited by
          #4

          Solved! Smth like this: <asp:DropDownList ID="Fclty_ddl" runat="server" AutoPostBack="True" OnSelectedIndexChanged="Fclty_ddl_SelectedIndexChanged"> </asp:DropDownList> <asp:DropDownList ID="Group_ddl" runat="server" AutoPostBack="True" OnSelectedIndexChanged="Group_ddl_SelectedIndexChanged"> </asp:DropDownList>

          protected void Page_Load(object sender, EventArgs e)
          {
          web = SPContext.Current.Web;
          fctLS = web.Lists["List1"]; // faculty list
          groupLS = web.Lists["List2"]; // group list with lookup from faculty list

                  if (!IsPostBack)
                  {
                      SPListItemCollection items1 = fctLS.Items;
                      DataTable dt1 = items1.GetDataTable();
                      Fclty\_ddl.DataSource = dt1;
                      Fclty\_ddl.DataValueField = "ID";
                      Fclty\_ddl.DataTextField = "Fclty";
                      Fclty\_ddl.DataBind();
          
                      SPListItemCollection items2 = groupLS.Items;
                      DataTable dt2 = items2.GetDataTable();
                      Group\_ddl.DataSource = dt2;
                      Group\_ddl.DataValueField = "ID";
                      Group\_ddl.DataTextField = "Group";
                      Group\_ddl.Enabled = false;
                      Group\_ddl.DataBind();
                   }
              }
          
              protected void Fclty\_ddl\_SelectedIndexChanged(object sender, EventArgs e)
              {
                  SPQuery queryq = new SPQuery();
                  queryq.Query = string.Format("<Where>" +
                                               "<Eq>" +
                                               "<FieldRef Name='Fclty' LookupId='True'/>" +
                                               "<Value Type='Lookup'>{0}</Value>" +
                                               "</Eq>" +
                                               "</Where>", Fclty\_ddl.SelectedValue);
                  SPListItemCollection items = groupLS.GetItems(queryq);
                  DataTable dt = items.GetDataTable();
                  Group\_ddl.DataSource = dt;
                  Group\_ddl.DataTextField = "Group";
                  Group\_ddl.DataValueField = "ID";
                  Group\_ddl.DataBind();
              }
          
          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups