sharepoint插入数据

View Code
 1      protected void btnsub_Click(object sender, EventArgs e)
 2         {
 3             try
 4             {
 5                 SPSecurity.RunWithElevatedPrivileges(delegate() 
 6                //提高权限
 7                 {
 8                     SPWeb web = SPContext.Current.Web;
 9                    //当前页
10                     SPList listLeaderMail = web.Lists["领导信箱"];
11                   //web.Lists后带的为sharepoint表单名称
12                     SPListItem logItem = listLeaderMail.Items.Add();
13                     logItem["name"] = txtname.Text;
14                     if (radfemal.Checked == true)
15                     {
16                         logItem["sex"] = radfemal.Text;
17                     }
18                     else
19                     {
20                         logItem["sex"] = radman.Text;
21                     }
22                     logItem["phone"] = txtphone.Text;
23                     logItem["age"] = txtage.Text;
24                     //logItem["dept"] = txtdept.Text;
25                     logItem["dept"] = ddldept.SelectedValue;
26                     logItem["eMail"] = txtemail.Text;
27                     logItem["Title"] = txttitle.Text;
28                     logItem["complaintsContent"] = txtcontent.Text;
29                     logItem["submitDate"] = DateTime.Now;
30                     logItem["handleStatus"] = "未处理";
31                     logItem["replyShow"] = "";
32                     // logItem["handleResult"] = "不显示";
33                     logItem.Update();//update
34     
35                     Page.ClientScript.RegisterStartupScript(this.GetType(), "leaderMailAlert", "<script>alert('提交成功!请耐心等候领导的回复!');window.location.href='default.aspx'</script>");
36                     //Response.Redirect("mailList.aspx");
37                 });
38 
39             }
40             catch (Exception ex)
41             {
42 
43                 SharePointUtility.WriteLog(ex);
44             }
45 
46         }
1  if (SPContext.Current.Web.CurrentUser != null)
2                     {
3                         txtname.Text = SPContext.Current.Web.CurrentUser.Name;
4      //LoginName为登录名
5                     }

 

posted @ 2012-09-17 11:44  double_ed  Views(159)  Comments(0Edit  收藏  举报