Cascading Dropdownlist
-
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?
-
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?
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!
-
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!
I'll try, thanks a lot!
-
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!
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 listif (!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(); }