项目总结

 1.绑定数据到dropDownlist,去掉重复的项。

public void bindModels()

    {
        string yh = Session["userName"].ToString();
        DataSet dsinfo = tiezibll.GetList(" creater='" + yh + "'");
        string idlist = "";
        if (dsinfo.Tables[0].Rows.Count > 0)
        {
            for (int i = 0; i < dsinfo.Tables[0].Rows.Count; i++)
            {
                string mid = dsinfo.Tables[0].Rows[i]["mid"].ToString();
                idlist += mid + ",";
            }

            string[] kk = idlist.Substring(0, idlist.LastIndexOf(",")).Split(',');
            List<string> liststring = new List<string>();
            foreach (string eachstr in kk)
            {
                if (!liststring.Contains(eachstr))
                {
                    liststring.Add(eachstr);
                }

            }
            string kkk = "";
            foreach (object s in liststring)
            {
                kkk += s + ",";
            }
            string newstr = kkk.Substring(0, kkk.LastIndexOf(","));

            DataSet ds = Modelbll.GetList(" id in (" + newstr + ")");
            if (ds.Tables[0].Rows.Count > 0)
            {
                datalist_models.DataSource = ds.Tables[0];
                datalist_models.DataBind();
            }
            else
            {
                datalist_models.DataSource = "";
                datalist_models.DataBind();
            }


        }
        else
        {

            datalist_models.DataSource = "";
            datalist_models.DataBind();

        }
    }


    public void Binddrop()
    {

        string yh = Session["userName"].ToString();
        DataSet dsinfo = tiezibll.GetList(" creater='" + yh + "'");
        string idlist = "";
        if (dsinfo.Tables[0].Rows.Count > 0)
        {
            for (int i = 0; i < dsinfo.Tables[0].Rows.Count; i++)
            {
                string mid = dsinfo.Tables[0].Rows[i]["mid"].ToString();
                idlist += mid + ",";
            }

            string[] kk = idlist.Substring(0, idlist.LastIndexOf(",")).Split(',');
            List<string> liststring = new List<string>();
            foreach (string eachstr in kk)
            {
                if (!liststring.Contains(eachstr))
                {
                    liststring.Add(eachstr);
                }

            }
            string kkk = "";
            foreach (object s in liststring)
            {
                kkk += s + ",";
            }
            string newstr = kkk.Substring(0, kkk.LastIndexOf(","));

            DataSet ds = Modelbll.GetList(" id in (" + newstr + ")");
            if (ds.Tables[0].Rows.Count > 0)
            {
                this.DropDownList1.DataSource = ds;
                this.DropDownList1.DataTextField = "Model_name";
                this.DropDownList1.DataValueField = "id";
                this.DropDownList1.DataBind();
            }
            else
            {
                this.DropDownList1.DataSource = ds;
                this.DropDownList1.DataTextField = "Model_name";
                this.DropDownList1.DataValueField = "id";
                this.DropDownList1.DataBind();
            }


        }
        else
        {

            this.DropDownList1.DataSource = null;
            this.DropDownList1.DataTextField = "Model_name";
            this.DropDownList1.DataValueField = "id";
            this.DropDownList1.DataBind();

        }

    }

B.数据绑定(反选)

  //datalist
        //foreach (DataListItem item in DL_Main.Items)
        //{
        //    CheckBox cb = (CheckBox)item.FindControl("selected");
        //    if (cb.Checked == false)
        //        cb.Checked = true;
        //    else
        //        cb.Checked = false;
        //}

        //repeater
        for (int i = 0; i < this.DL_Main.Items.Count; i++)
        {

            CheckBox cb = (CheckBox)DL_Main.Items[i].FindControl("selected");
            if (cb.Checked == false)
                cb.Checked = true;
            else
                cb.Checked = false;
        }

//查询数组里是否包含指定的字符。

 

string[] fwlist = serverlist.Split('-');

            bool k = fwlist.Contains<string>("72");

ItemDataBound事件

   if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {

            HyperLink jr = (HyperLink)e.Item.FindControl("jr_qianyue");//链接(查询reapter的服务器控件)

 string code = DataBinder.Eval(e.Item.DataItem, "MNCode").ToString();(取前台用eval绑定的数据)


}

  <%#Eval("Ischarge").ToString() == "0" || Eval("Ischarge").ToString() == ""? "免费" : "价格:<span style='color:red;'>" + Eval("price").ToString() + "元</span>"%> 

<%#Eval("Model_name").ToString().Length >10? Eval("Model_name").ToString().Substring(0, 10) + "....." : Eval("Model_name").ToString()%>

<asp:HyperLink id=Hyperlink3 runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ID") %>' Visible="False">

System.Web.UI.HtmlControls.HtmlAnchor linkSend = ((System.Web.UI.HtmlControls.HtmlAnchor)e.Item.FindControl("linkSend"));(查找reapter绑定数据之间的html控件

 string rptime =DateTime.Parse( ds_hf.Tables[0].Rows[0]["ReplayTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");(显示24小时制的时间)

C.编辑器加载需要的菜单

    <script src="kindeditor-4.1.10/lang/zh_CN.js" type="text/javascript"></script>
    <script src="kindeditor-4.1.10/kindeditor.js" type="text/javascript"></script>
    <script src="kindeditor-4.1.10/plugins/code/prettify.js" type="text/javascript"></script>
    <script src="js/jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">

        KindEditor.ready(function (K) {

            editor = K.create('#contentqq', {

                items: ["source", "|", "undo", "redo", "|", "preview", "print", "template", "code", "cut", "copy", "paste", "plainpaste", "wordpaste",

"|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "insertorderedlist", "insertunorderedlist", "indent", "outdent", "subscript", "superscript", "clearhtml", "quickformat", "selectall", "|", "fullscreen", "/", "formatblock", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline", "strikethrough", "lineheight", "removeformat", "|", "image", "flash", "media", "insertfile", "table", "hr", "emoticons", "baidumap", "pagebreak", "anchor", "link", "unlink", "|", "about"],
                afterBlur: function () { this.sync(); }

            });
           
        });
       
    </script>



你可能感兴趣的:(项目总结)