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

  • 相关阅读:
    DevExpress控件开发常用要点(项目总结版)
    DevExpress BarManager 部分用法
    DevExpress LookUpEdit和ComboBoxEdit部分用法
    DevExpress GridControl 部分用法
    DevExpress 中 WaitForm 使用
    DevExpress汉化(WinForm)
    DevExpress 使用 XtraTabbedMdiManager 控件以 Tab样式加载 Mdi窗体并合并 RibbonControl 解决方案
    DevExpress 关于 GridView 表格编辑中 点击其他按钮里导致 值未取到处理
    DevExpress 中 在做全选的全消功能的时候 加快效率
    DevExpress后置代码中初始化SQL数据源的方法
  • 原文地址:https://www.cnblogs.com/KingStar/p/1594557.html
Copyright © 2011-2022 走看看