• SharePoint CMAL方式处理的 增,删,查,改


     SPContext.Current.Web.Lists["UserInfo"]:获取网站的List,名称是:UserInfo
     userlist.AddItem():添加数据到List里
     user.Update():将数据保存到List里,更新的List里的数据
     GetItemById:获取当前行的ID
     query.Query (XML的方式条件):过滤查询条件
     

      protected void bt_SaveClick(object sender, EventArgs e)
            {
                SPList userlist = SPContext.Current.Web.Lists["UserInfo"];
                SPListItem user = userlist.AddItem();
                user["Title"] = this.tx_Title.Text;
                user["UserName"]  = this.tx_UserName.Text;
                user["Gender"] = this.tx_Gender.Text;
                user["Tell"]  = this.tx_tell.Text;
                user["Adress"]  = this.tx_adress.Text;
                user.Update();
               
                base.Response.Redirect("UserInfoList.aspx");
            }

       protected void bt_DeleteClick(object sender, EventArgs e)
            {
                using (Site9527EntitiesDataContext dataContext = new Site9527EntitiesDataContext(SPContext.Current.Web.Url))
                {
                    SPList userList = SPContext.Current.Web.Lists["UserInfo"];
                    SPListItem user = userList.GetItemById(Convert.ToInt32(tx_Del.Text));
                    user.Delete();
                }
                tx_Del.Text = "";
                bt_SelectClick(sender, e);
            }

      public void bt_SelectClick(object sender, EventArgs e)
            {
                StringBuilder html = new StringBuilder();
                SPList userList = SPContext.Current.Web.Lists["UserInfo"];
                SPListItemCollection users = null;
                if (!string.IsNullOrEmpty(tb_UserName.Text))
                {
                    SPQuery query = new SPQuery();
                    query.Query = "<Where><Contains><FieldRef Name='UserName' /><Value Type='Text'>" + tb_UserName.Text + "</Value></Contains></Where>";
                    users = userList.GetItems(query);
                }
                else
                {
                    users = userList.Items;
                }
    
                foreach (SPListItem user in users)
                {
                    html.Append("<tr>");
                    html.Append("<td>" + user.Title);
                    html.Append("</td>");
                    html.Append("<td>" + ConvertoString(user["UserName"]));
                    html.Append("</td>");
                    html.Append("<td>" + ConvertoString(user["Gender"]));
                    html.Append("</td>");
                    html.Append("<td>" + ConvertoString(user["Tell"]));
                    html.Append("</td>");
                    html.Append("<td>" + ConvertoString(user["Adress"]));
                    html.Append("</td>");
                    html.Append("<td>" + ConvertoString(user["ApprovalStatue"]));
                    html.Append("</td>");
                    html.Append("<td>" + ConvertoString(user["ApprovalBy"]));
                    html.Append("</td>");
                    html.Append("<td><a  id='a_update' onclick='Update(" + user.ID.ToString() + ")'>更新</a>  <a  id='a_delete' onclick='Delete(" + user.ID.ToString() + ")'>删除</a>");
                    html.Append("</td>");
                    html.Append("</tr>");
                }
    }

      protected void bt_SaveClick(object sender, EventArgs e)
            {
                SPList userlist = SPContext.Current.Web.Lists["UserInfo"];
                SPListItem user = userlist.GetItemById(Convert.ToInt32(Request.QueryString["ID"]));
                user["Title"] = this.tx_Title.Text;
                user["UserName"] = this.tx_UserName.Text;
                user["Gender"] = this.tx_Gender.Text;
                user["Tell"] = this.tx_tell.Text;
                user["Adress"] = this.tx_adress.Text;
                user.Update();
                
                base.Response.Redirect("UserInfoList.aspx");
            }
  • 相关阅读:
    Xcode8 1 创建coreData的ManagedObject后,报错 linker command failed with exit code 1
    在IOS中根据圆心坐标、半径和角度计算圆弧上的点坐标
    NodeJS学习目录
    nodeJS之URL
    nodeJS之域名DNS
    初识nodeJS
    使用nodeJS实现前端项目自动化之项目构建和文件合并
    nodeJS之fs文件系统
    nodeJS之二进制buffer对象
    nodeJS之进程process对象
  • 原文地址:https://www.cnblogs.com/liuwj/p/3881269.html
Copyright © 2020-2023  润新知