zoukankan      html  css  js  c++  java
  • SPQuery如何消除重复记录(实现联动性)

    列表:

    实现大类与小类的联动性

      private void BindIncidentCategory()
            {
                using (SPSite site = new SPSite(rootsiteurl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList list = web.Lists["IncidentCategory"];
                        SPListItemCollection listitem = list.Items;
                        DataTable dt = listitem.GetDataTable();

                        DataView dvSort = new DataView(dt);
                        string[] colName = new string[] { "CategoryName" };
                        DataTable dtLargeSort = dvSort.ToTable(true, colName);

                        DropDownListIncidentCategory.DataValueField = "CategoryName";
                        DropDownListIncidentCategory.DataValueField = "CategoryName";
                        DropDownListIncidentCategory.DataSource = dtLargeSort;
                        DropDownListIncidentCategory.DataBind();
                     
                       BindIncidentSubCategory(DropDownListIncidentCategory.SelectedItem.Text);
                       
                    }
                }

            }


     
            private void BindIncidentSubCategory(string IncidentCategory)
            {
                using (SPSite site = new SPSite(rootsiteurl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList list = web.Lists["IncidentCategory"];
                        SPQuery query = new SPQuery();
                        query.Query = "<Where><Eq><FieldRef Name='CategoryName'/><Value Type='Text'>"+IncidentCategory+"</Value></Eq></Where>";
                        SPListItemCollection listitem = list.GetItems(query);
                        DataTable dt = listitem.GetDataTable();
                        DropDownListIncidentSubCategory.DataTextField = "SubCategoryName";
                        DropDownListIncidentSubCategory.DataValueField = "SubCategoryName";
                        DropDownListIncidentSubCategory.DataSource = dt;
                        DropDownListIncidentSubCategory.DataBind();
                    }
                }
            }

       protected void DropDownListIncidentCategory_SelectedIndexChanged(object sender, EventArgs e)
            {
                BindIncidentSubCategory(DropDownListIncidentCategory.SelectedItem.Text.Trim());

            }

    注意要把DropDownListIncidentCategory中AutoPostBack属性设成true

  • 相关阅读:
    CSS基础知识
    CSS3 zoom 属性
    jenkins安装与配置
    CSS——字体大小最常用的单位
    CSS——简写属性(在padding和margin这样的简写属性中,值赋值的顺序是top、right、bottom、left)
    方正科技win7重装系统
    vue+axios 前端实现登录拦截(路由拦截、http拦截)
    基于 Token 的身份验证:JSON Web Token
    Session与Token认证机制 前后端分离下如何登录
    ajax请求携带 cookie
  • 原文地址:https://www.cnblogs.com/KingStar/p/1594557.html
Copyright © 2011-2022 走看看