Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Create a list in SharePoint Programatically using C#
WhatsApp
Gowtham Rajamanickam
10y
16.5
k
0
1
25
Blog
Actually this is very simple task; this is a sample code.call the below function in your code or try with a console application in vs 2010/2012.
public
void
createList()
{
using (SPSite osite =
new
SPSite(
"http://Enter url sharepoint site url"
))
{
osite.AllowUnsafeUpdates =
true
;
using (SPWeb oweb= osite.OpenWeb())
{
oweb.AllowUnsafeUpdates =
true
;
// create new Generic list called "My List"
oweb.Lists.Add(
"List Name"
,
"Description"
, SPListTemplateType.GenericList);
// create Text type new column called "My Column"
SPList list = oweb.Lists[
"List Name"
];
list.Fields.Add(
"My Column"
, SPFieldType.Text,
true
);
oSPWeb.AllowUnsafeUpdates =
false
;
}
oSPsite.AllowUnsafeUpdates =
false
;
}
}
People also reading
Membership not found