Exemple #1
0
        protected void Repeater_News_List_DataBind()
        {
            DataTable dt = new NewsPub().SelectAll().Tables[0];

            if (dt != null)
            {
                dt.Columns.Add("Operate", typeof(string));   //操作(修改,删除)
                dt.Columns.Add("Colum", typeof(String));     //在dt中增加字段名为Colum的列
                DataRow[] drs = dt.Select("");
                foreach (DataRow dr in drs)
                {
                    string strchar = null;
                    string classID = dr["ID"].ToString();
                    dr["operate"] = "<a href=\"NewsClass_Add.aspx?action=modify&ClassID=" + classID + "\"  class=\"op_normal\">修改</a><a href=\"NewsClass_List.aspx?action=delone_class&ClassID=" + classID + "\" "
                                    + " class=\"op_normal\"  onclick=\"{if(confirm('确认删除吗?')){return true;}return false;}\">删除</a>"
                                    //  + "<a href=\"NewsClass_List.aspx?action=valid&ClassID=" + classID + "\"  class=\"op_normal\"  onclick=\"{if(confirm('确认将新闻作过期处理吗?')){return true;}return false;}\">过期</a>"
                                    + " <input type='checkbox' name='define_checkbox' id='define_checkbox' value=\"" + classID + "\"/>";

                    strchar    += "<tr class=\"TR_BG_list\" onmouseover=\"this.style.backgroundColor='#BEFBD1'\" onmouseout=\"this.style.backgroundColor='#FFFFFF'\">";
                    strchar    += "<td width=\"30%\" align=\"left\" valign=\"middle\">" + dr["ClassName"].ToString() + "</td>";
                    strchar    += "<td align=\"center\" valign=\"middle\" >" + dr["Summary"].ToString() + "</td>";
                    strchar    += "<td align=\"center\" valign=\"middle\" >" + dr["operate"].ToString() + "</td>";
                    strchar    += "</tr>";
                    dr["Colum"] = strchar;
                }

                Repeater_NewsClass_List.DataSource = dt;
                Repeater_NewsClass_List.DataBind();
            }
        }
Exemple #2
0
        private void Repeater_News_Search()
        {
            string    html = NewsTitle.Value.Trim();
            DataTable dt   = new NewsContentPub().GetNewsByTitle(html).Tables[0];

            if (dt != null)
            {
                dt.Columns.Add("Operate", typeof(string));   //操作(修改,删除)
                dt.Columns.Add("Colum", typeof(String));     //在dt中增加字段名为Colum的列
                DataRow[] drs = dt.Select("");
                foreach (DataRow dr in drs)
                {
                    string strchar = null;
                    string newsID  = dr["ID"].ToString();
                    dr["operate"] = "<a href=\"NewsAdd.aspx?action=modify&NewsID=" + newsID + "\"  class=\"op_normal\">修改</a><a href=\"NewsList.aspx?action=delone_News&NewsID=" + newsID + "\" "
                                    + " class=\"op_normal\"  onclick=\"{if(confirm('确认删除吗?')){return true;}return false;}\">删除</a>"
                                    + "<a href=\"NewsList.aspx?action=valid&NewsID=" + newsID + "\"  class=\"op_normal\"  onclick=\"{if(confirm('确认将新闻作过期处理吗?')){return true;}return false;}\">过期</a>"
                                    + " <input type='checkbox' name='define_checkbox' id='define_checkbox' value=\"" + newsID + "\"/>";

                    strchar    += "<tr class=\"TR_BG_list\" onmouseover=\"this.style.backgroundColor='#BEFBD1'\" onmouseout=\"this.style.backgroundColor='#FFFFFF'\">";
                    strchar    += "<td width=\"30%\" align=\"left\" valign=\"middle\">" + dr["Title"].ToString() + "</td>";
                    strchar    += "<td align=\"center\" valign=\"middle\" >" + dr["ClassName"].ToString() + "</td>";
                    strchar    += "<td align=\"center\" valign=\"middle\" >" + dr["AddTime"].ToString() + "</td>";
                    strchar    += "<td align=\"center\" valign=\"middle\" >" + dr["UserName"].ToString() + "</td>";
                    strchar    += "<td align=\"center\" valign=\"middle\" >" + dr["DepartMentName"].ToString() + "</td>";
                    strchar    += "<td align=\"center\" valign=\"middle\" >" + dr["operate"].ToString() + "</td>";
                    strchar    += "</tr>";
                    dr["Colum"] = strchar;
                }
                AspNetPager1.RecordCount = dt.Rows.Count;
                PagedDataSource pds = new PagedDataSource();
                pds.AllowPaging      = true;
                pds.PageSize         = AspNetPager1.PageSize;
                pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
                pds.DataSource       = dt.DefaultView;
                Repeater_NewsClass_List.DataSource = dt;
                Repeater_NewsClass_List.DataBind();
            }
        }