I need to get all fields from my list template?
How can i do this?
var web = site.OpenWeb();
var template = web.ListTemplates["SomeTemplate"];
template ... ???? -There is no method to get fields.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no built-in method to get all fields from a list template. The only way you can get the fields is by parsing the Schema XML of the list and getting all
<Field>and<FieldRef>tags.Easier is to create a list instance, which you can query later on with the following examples.
To get all fields from a list you can use the
SPList.FieldsProperty, e.g. like so:MSDN SPListItem.Fields
You can also get all fields from a list item “in reverse”
SPListItem.FieldsProperty. You might also be interested in this SO thread: Check if a List Column Exists using SharePoint Client Object Model?