1. Go to the list and choose Settings | List Settings
2. Click "Advanced settings"
3. Change the first entry, "Allow management of content types?" to Yes
4. In the “Content Types” section that has just appeared, click the "Item" link
5. Click the "Title" field and select “Hidden (will not appear on forms)”
6. Change the management of content types back to “No” (steps 1-2)
Showing posts with label SharePoint list field. Show all posts
Showing posts with label SharePoint list field. Show all posts
Wednesday, October 12, 2016
Thursday, March 19, 2015
Bind SharePoint list field names in to Dropdownlist/Checkbox
Suppose that you have a list and you created some fields(columns) in that list.Then you need to display these columns in a visual web part when the page is loading.To do this just use below code in your page_load method in the visual webpart project.
Display columns which you created.
protected void Page_Load(object sender, EventArgs e)
{
SPWeb spweb = SPContext.Current.Web;
SPList List = spweb.GetList("Type url for the list");
SPFieldCollection spfieldcollection = List.Fields;
ListItemCollection ListColumnNames = new ListItemCollection();
if (spfieldcollection.Count != 0)
{
foreach (SPField field in spfieldcollection)
{
if (!field.FromBaseType)
{
ListColumnNames.Add(new ListItem(field.Title));
}
}
}
dropdowncontrol.DataSource = ListColumnNames;
dropdowncontrol.DataBind();
}
Display all columns
protected void Page_Load(object sender, EventArgs e)
{
SPWeb spweb = SPContext.Current.Web;
SPList List = spweb.GetList("Type url for the list");
SPFieldCollection spfieldcollection = List.Fields;
ListItemCollection ListColumnNames = new ListItemCollection();
if (spfieldcollection.Count != 0)
{
foreach (SPField field in spfieldcollection)
{
ListColumnNames.Add(new ListItem(field.Title));
}
}
dropdowncontrol.DataSource = ListColumnNames;
dropdowncontrol.DataBind();
}
For the checkboxlist you change "dropdowncontrol" in to "checkboxlistcontrol".
checkboxlistcontrol.DataSource = ListColumnNames;
checkboxlistcontrol.DataBind();
Subscribe to:
Posts (Atom)