how to make an additional column to a list?
-
2012년 4월 14일 토요일 오전 6:39
I made a custom list on task.
I want to add a column to the list with VS.
How to do that?
- 유형 변경됨 Ronaldo.K 2012년 4월 14일 토요일 오전 7:03
모든 응답
-
2012년 4월 14일 토요일 오전 7:30
If list is created using custom listdefintion template "Tasks" then you can directly add Field tag in schema.Which will create field to the list.
If you have created list from UI, then you can write code to create field to it.
Options to create field would by creating console application, powershell script or binding code in feature receiver.
Check code to create field in below articles
http://allaboutmoss.com/2011/02/04/creating-sharepoint-list-and-add-column-programmatically/
Regards,Milan Chauhan
- 편집됨 Milan Chauhan 2012년 4월 14일 토요일 오전 7:30
- 편집됨 Milan Chauhan 2012년 4월 14일 토요일 오전 7:42
- 답변으로 제안됨 Ahmed Naji 2012년 4월 14일 토요일 오전 8:33
- 답변으로 표시됨 Ronaldo.K 2012년 4월 14일 토요일 오후 10:11
-
2012년 4월 14일 토요일 오전 8:07중재자
Use the SPFieldCollection.Add Method
using (SPSite site = new SPSite("your_site_url"))
{
using (SPWeb web = site.OpenWeb())
{
try
{
SPList list = web.Lists["your_custom_list"];
list.Fields.Add("FieldName",SPFieldType.Text,false);
list.Update();
}
catch (Exception ex)
{
string message = ex.Message;
}
}If the field is requierd to contain a value ,change the last param to true
http://msdn.microsoft.com/en-us/library/ms472869.aspx
Regards
Bjoern
- 답변으로 제안됨 Ahmed Naji 2012년 4월 14일 토요일 오전 8:33
- 답변으로 표시됨 Ronaldo.K 2012년 4월 14일 토요일 오후 10:11
-
2012년 4월 14일 토요일 오전 8:58I want to know how to modify schema.xml file.
-
2012년 4월 14일 토요일 오전 10:41중재자
In short, you have to edit the <Fields> and <ViewFields> elements .
The following links should be useful:
http://msdn.microsoft.com/en-us/library/ms459356.aspx
http://msdn.microsoft.com/en-us/library/ff728096.aspx
Regards Bjoern
- 답변으로 표시됨 Ronaldo.K 2012년 4월 14일 토요일 오후 10:10

