jeudi 29 janvier 2015

List Field Iterator Create New Item by Code



I have a web part and I dynamically add a List field iterator to it:



//contentType is the content type ID

SPList list = web.Lists[listName];

SPContentType spct = web.AvailableContentTypes[contentTypeName];
Iterator = new ListFieldIterator()
{
ControlMode = SPControlMode.Display,
TemplateName = spct.NewFormTemplateName,
ListId = list.ID
};
Iterator.ListItem["ContentTypeId"] = contentType;
Iterator.EnableViewState = true;

var currentMode = SPControlMode.New;
Iterator.ControlMode = currentMode;
PlaceHolder p1 = (PlaceHolder)this.FindControl("PlaceHolder1");
p1.Controls.Add(Iterator);


I have 2 questions:




  1. How I can hide the buttons that appear with the list field iterator?




  2. I want to add a method that create the item (Library list item with attachment) by code, by reading the item of list field iterator and create it, how I can do it?










0 commentaires:

Enregistrer un commentaire