Uncategorized

Populate DropDownList from List in SharePoint 2010 Visual Web Part

SPWeb web = SPControl.GetContextWeb(HttpContext.Current);
                SPList supervisorList = web.Lists["SupervisorList"];

                if(supervisorList !=null)
                {
                    ddlSupervisor.Items.Clear();
                    foreach (SPListItem items in supervisorList.Items)
                    {
                        string supervisorName = items["SupervisorName"].ToString();
                        ddlSupervisor.Items.Add(supervisorName);
                    }
                    ddlSupervisor.DataBind();
                }

Standard
Uncategorized

Get all Groups of the Site and Groups of current loggedIn User in SharePoint 2010 porgrammatically

SPWeb web = SPContext.Current.Web;

//Retreiving the current logged in user
SPUser currentUser = web.CurrentUser;

// Get all the Groups of the Current Site
SPGroupCollection allGroups = web.Groups;

//Retrieving all the groups in the site/web by specific user
SPGroupCollection userGroups = currentUser.Groups;

string groupName_Member = "FirstSiteColl Members";
//Check is Current user a member of specific Group
bool memberInGroup = web.IsCurrentUserMemberOfGroup(userGroups[groupName_Member].ID);

Standard
Uncategorized

How to add an Item in SP List in SharePoint 2010

here web is the SPWeb object that is my Root Site on which am going to add an Item in the list named MyList

using (SPSite currentSite = new SPSite(siteUrl))
{
SPWeb web = currentSite.RootWeb;
SPListItemCollection listItemCollection = web.Lists["MyList"].Items;
SPListItem spListItem = listItemCollection.Add();
spListItem["Title"] = "Anything";
spListItem["CustomerName"] = "Shahjada";
spListItem["Address"] = "Dhaka";
spListItem.Update();
}

Standard
Uncategorized

What is Site collection in SharePoint?

SharePoint site collection is a logical grouping of multiple SharePoint site or hierarchical site structure. For e.g. Sites of various teams or departments of an organization can be grouped logically in one site collection. A site collection consists of a top-level site and one or more sites below it. Each top-level site and any sites below it in the site structure are based on a site template and can have other unique settings and content. Hence, SharePoint site collection is a hierarchical set of sites that can be managed together. Sites within a site collection have common features, such as shared permissions, galleries for templates, content types, and Web Parts, and they often share a common navigation. A sub site can inherit permissions and navigation structure from its parent site or these can be specified and managed independently. Creation of sub sites can be delegated to users of a site collection, but a service administrator must perform creation of site collections

Standard