Click here to Skip to main content
11,929,950 members (63,627 online)
Rate this:
Please Sign up or sign in to vote.
See more: SharePoint
I have created one list..inside that I placed one drop down..Depending on the option selected I need to show/hide the another colummn
Is it possible in SharePoint Web part?
Posted 26-Feb-13 0:51am
Edited 26-Feb-13 3:26am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

this can be done using CAML query..

public  void PopulateCompanyDropDown()
            SPSite Site = new SPSite("http://xss-422:8000/default.aspx");
            SPWeb web = Site.OpenWeb();
            SPList SourceList1 = web.Lists["Company"];
            this.ddCompany.DataSource = SourceList1.Items.GetDataTable();
            this.ddCompany.DataTextField = "Title";
            this.ddCompany.DataValueField = "ID";

        public  void PopulateDepartmentDropDown()
            SPSite Site = new SPSite("http://xss-422:8000/default.aspx");
            SPWeb Web = Site.OpenWeb();
            SPList SourceList2 = Web.Lists["Department Name"];
            //foreach (SPListItem item in SourceList2.Items)
            //    Console.WriteLine(item.Title.ToString());
            //    Console.WriteLine(item.Fields[9].ToString());

            string caml = "<Where>" +
                      "<Eq>" +
                          "<FieldRef Name='{0}'/>" +
                          "<Value Type=\"Lookup\">{1}</Value>" +
                      "</Eq>" +
            SPQuery query = new SPQuery();
            string CompanyName = ddCompany.SelectedItem.Text.ToString();
            query.Query = string.Format(caml, "Company_x0020_Name", CompanyName);
            SPListItemCollection results = SourceList2.GetItems(query);
            this.ddDepartment.DataSource = results.GetDataTable();
            this.ddDepartment.DataTextField = "Title";
            this.ddDepartment.DataValueField = "ID";
            //txtManager.Text = SourceList2.Items[2]["Manager"].ToString();
            //txtUserName.Text = SourceList2.Items[2]["UserName"].ToString();
            //txtAddress.Text = SourceList2.Items[2]["UserComment"].ToString();
            //DataTable dtttt = results.
            //txtAddress.Text = SourceList2.Fields["UserComment"].ToString();
            DataTable dtttt = results.GetDataTable();
  protected void ddCompany_SelectedIndexChanged(object sender, EventArgs e)


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100