如何使用.net Windows应用程序在共享点站点中添加项目?请尽快帮助 [英] How to add items in a share point site using .net windows application? plz help asap

查看:58
本文介绍了如何使用.net Windows应用程序在共享点站点中添加项目?请尽快帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个新的Windows应用程序,在共享点网站的列表中添加项目

在我的应用程序中,我想从excel导出数据,需要将该数据粘贴到sharepoint站点。

这怎么可能?

如何使用C#progarm(Windows应用程序)在列表中添加项目。

I want to create a new windows application to add items in list in share point site
In my application i wanna export data from excel and need to paste that data in sharepoint site.
How this possible?
How can i add items in list using C# progarm ( Windows application ).

推荐答案

private void button1_Click(object sender,EventArgs e)

{

try

{

string siteUrl =Site URL ;

string strname = textBox1.Text;

int intage = Convert.ToInt32(textBox2.Text);



ClientContext clientContext = new ClientContext(siteUrl);

SP.List oList = clientContext.Web.Lists.GetByTitle(Test_C#);



ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();

ListItem oListItem = oList.AddItem(itemCreateInfo);

oListItem [Title] =Test;

oListItem [Name] = strname;

oListItem [Age] = intage;



oListItem.Update();





clientContext.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

clientContext.ExecuteQuery();

MessageBox.Show(Item Added,SharePointListItem);





}

catch(例外exe)

{

MessageBox.Show(Error+ exe );



}





}
private void button1_Click(object sender, EventArgs e)
{
try
{
string siteUrl = "Site URL";
string strname = textBox1.Text;
int intage = Convert.ToInt32(textBox2.Text);

ClientContext clientContext = new ClientContext(siteUrl);
SP.List oList = clientContext.Web.Lists.GetByTitle("Test_C#");

ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem oListItem = oList.AddItem(itemCreateInfo);
oListItem["Title"] = "Test";
oListItem["Name"] = strname;
oListItem["Age"] = intage;

oListItem.Update();


clientContext.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
clientContext.ExecuteQuery();
MessageBox.Show("Item Added", "SharePointListItem");


}
catch (Exception exe)
{
MessageBox.Show("Error" + exe);

}


}


这篇关于如何使用.net Windows应用程序在共享点站点中添加项目?请尽快帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆