Friday, August 26, 2011

Sunday, August 21, 2011

Retrieve data form SharePoint list and populate in asp.net DropdownList

If you need populate data form a list and show in a dropdown list, it easy when you create a String type list then it can assign to Dropdown list’s “Data Source” below code illustrate how it can done

        private List LoadDropDownList(SPList spList)
        {
            SPQuery  quary = new SPQuery();
            SPListItemCollection titleItems = spList.GetItems(quary);

            List howList = new List();

            if (titleItems.Count>0)
            {
                foreach (SPListItem titleitem in titleItems)
                {
                    howList.Add(titleitem["Title"].ToString());
                }
            }
            else
            {
                howList.Add("No records to load");
            }

            return howList;            
        }

Then you can easyly assign that string type list to Dropdown “Data Source” as follows

howDropDownList.DataSource = LoadDropDownList(findOutlist);
howDropDownList.DataBind();

Friday, August 19, 2011

Set and Get value from the CRM2011 optionset

In CRM 2011 Jscript its totally different than the CRM4 So today I will show you how to set and get data form an option set. Following codes are demonstrate that

Get Values from the CRM2011 Optionset
Xrm.Page.getAttribute().getValue();

OptionField will be your attribute name

Set values to the CRM2011 Optionset

Xrm.Page.getAttribute().setValue('1');

OptionField will be your attribute name