- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章对GridView的行加颜色并弹出Kindeditor的实现思路由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
前台代码: 。
复制代码代码如下
<head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript"> function tureDelete() { if (confirm('真的要删除吗?') == false) { return false;} } function showdiv() { document.getElementByIdx_x("show1").style.display = "block"; document.getElementByIdx_x("showDiv").style.display = "block"; } </script> <link rel="stylesheet" href="Kindeditor/themes/default/default.css" /> <link rel="stylesheet" href="Kindeditor/plugins/code/prettify.css" /> <script charset="utf-8" src="Kindeditor/kindeditor.js"></script> <script charset="utf-8" src="Kindeditor/lang/zh_CN.js"></script> <script charset="utf-8" src="Kindeditor/plugins/code/prettify.js"></script> <script> KindEditor.ready(function (K) { var editor1 = K.create('#content1', { cssPath: 'Kindeditor/plugins/code/prettify.css', uploadJson: 'Kindeditor/asp.net/upload_json.ashx', fileManagerJson: 'Kindeditor/asp.net/file_manager_json.ashx', allowFileManager: true, afterCreate: function () { var self = this; K.ctrl(document, 13, function () { self.sync(); K('form[name=example]')[0].submit(); }); K.ctrl(self.edit.doc, 13, function () { self.sync(); K('form[name=example]')[0].submit(); }); } }); prettyPrint(); }); </script> <style type="text/css"> #showDiv { position:absolute; top:50%; left:50%; margin-left:-350px; margin-top:-250px; } </style> </head> <body> <asp:Label ID="Label1" runat="server" Visible="false" Text=""></asp:Label> <form id="form1" runat="server"> <div id="show1" style="display:none;background-color: Black;position:absolute; width:100%;height:100%;top:0px;left:0px; opacity:0.3;"></div> <div id="showDiv" style="display:none;background-color:bisque;"> <table> <tr> <td> 标题 </td> <td> <asp:TextBox ID="txtTitle" runat="server" Width="250px"></asp:TextBox> </td> </tr> <tr> <td> 内容 </td> <td> <textarea id="content1" cols="100" rows="8" style="width:700px;height:500px;visibility:hidden;" runat="server"></textarea> </td> </tr> <tr> <td> 类别 </td> <td> <asp:DropDownList ID="ddlClassName" runat="server"> </asp:DropDownList> </td> </tr> <tr> <td> 用户 </td> <td> <asp:DropDownList ID="ddlUser" runat="server"> </asp:DropDownList> </td> </tr> <tr> <td align="center" colspan="2"> <asp:Button ID="btnUpdate" runat="server" Text="保存" /> </td> </tr> </table> </div> <div > <table> <tr> <td> <asp:GridView ID="GridView1" runat="server" AllowSorting="True" OnSorting="GridView1_Sorting" OnRowDataBound="GridView1_RowDataBound" ShowFooter="True"> <Columns> <asp:TemplateField HeaderText="选择"> <ItemTemplate> <asp:CheckBox ID="ck1" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="标题"> <ItemTemplate> <a href='WebForm1.aspx?id=<%#eval_r("Id") %>'><%#eval_r("NewsTitle") %></a> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="NewsContent" HeaderText="内容" /> <asp:BoundField DataField="RealName" HeaderText="创建者" SortExpression="RealName" /> <asp:BoundField DataField="CreateTime" DataFormatString="{0:yyyy-mm-dd hh:mm:ss}" HeaderText="创建时间" SortExpression="CreateTime" /> <asp:BoundField DataField="ClassName" HeaderText="类型" /> <asp:TemplateField HeaderText="操作"> <ItemTemplate> <asp:LinkButton ID="linkbtnEdit" CommandArgument='<%# eval_r("Id") %>' runat="server">编辑</asp:LinkButton> <asp:LinkButton ID="linkDelete" CommandArgument='<%# eval_r("Id") %>' runat="server">删除</asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </td> </tr> <tr> <td> <asp:LinkButton ID="lbtnFirst" runat="server" OnClick="lbtnFirst_Click">第一页</asp:LinkButton> <asp:LinkButton ID="lbtnProc" runat="server" OnClick="lbtnProc_Click">上一页</asp:LinkButton> <asp:LinkButton ID="lbtnNext" runat="server" OnClick="lbtnNext_Click">下一页</asp:LinkButton> <asp:LinkButton ID="lbtnLast" runat="server" OnClick="lbtnLast_Click">最后一页</asp:LinkButton> <asp:Button ID="Button1" runat="server" Text="删除" OnClick="Button1_Click" OnClientClick="return tureDelete()" /> <asp:Button ID="Button2" runat="server" Text="弹出层" OnClick="Button2_Click1" /> </td> </tr> </table> </div> </form> </body> 。
后台代码: 。
复制代码代码如下
public partial class GridView : System.Web.UI.Page { string constr = "data source=.;initial catalog=News;user id=sa;password=111111;"; string sql = "select T1.Id,T1.NewsTitle,SUBSTRING(T1.NewsContent,0,20) as NewsContent,T2.RealName,T1.CreateTime,T3.ClassName from (select ROW_NUMBER() over (order by Id) as rownumber,* from T_News) T1 left join T_User T2 on T1.NewsCreator=T2.UserId left join T_NewsClass T3 on T1.ClassId=T3.ClassId where rownumber>(@pageIndex-1)*@pageSize and rownumber<=@pageIndex*@pageSize"; int count; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["pageIndex"] = 1; DataPage(sql); } } private void DataPage(string sql) { SqlConnection conn = new SqlConnection(constr); conn.Open(); SqlCommand cmd = conn.CreateCommand(); // string sql = "select T1.Id,T1.NewsTitle,SUBSTRING(T1.NewsContent,0,20) as NewsContent,T2.RealName ,T1.CreateTime,T3.ClassName from T_News1 T1 join T_User T2 on T1.NewsCreator=T2.UserId join T_NewsClass T3 on T1.ClassId=T3.ClassId"; cmd.Parameters.AddWithValue("@pageSize", 10); cmd.Parameters.AddWithValue("@pageIndex", Convert.ToInt32(ViewState["pageIndex"])); cmd.CommandText = sql; SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); adapter.Fill(dt); string sql1 = "select count(*) from T_News"; cmd.CommandText = sql1; int i =Convert.ToInt32(cmd.ExecuteScalar()); if (i % 10 == 0) { ViewState["pageCount"] = i / 10; } else { ViewState["pageCount"] = i / 10+1; } conn.Close(); conn.Dispose(); GridView1.DataSource = dt; GridView1.DataBind(); } protected void lbtnFirst_Click(object sender, EventArgs e) { ViewState["pageIndex"] = 1; DataPage(sql); } protected void lbtnProc_Click(object sender, EventArgs e) { int i=Convert.ToInt32(ViewState["pageIndex"]) ; if (i>1) { i--; ViewState["pageIndex"] = i; DataPage(sql); } } protected void lbtnNext_Click(object sender, EventArgs e) { int i = Convert.ToInt32(ViewState["pageIndex"]); if (i <Convert.ToInt32(ViewState["pageCount"])) { i++; ViewState["pageIndex"] = i; DataPage(sql); } } protected void lbtnLast_Click(object sender, EventArgs e) { ViewState["pageIndex"] = ViewState["pageCount"]; DataPage(sql); } protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { if (ViewState["sortExp"] == null) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add(e.SortExpression, "ASC"); ViewState["sortExp"] = dic; sql += " Order by " + e.SortExpression + " " + dic[e.SortExpression]; DataPage(sql); } else { //判断用户本次点击的排序字段是否和上次点击的排序字段一致,如果一致的话,那么就更改此字段的排序规则,如果不是就清除上次的排序字段,添加新的排序字段和规则(这是根据一个字段排序的情况) Dictionary<string, string> dic = ViewState["sortExp"] as Dictionary<string, string>; if (dic.ContainsKey(e.SortExpression)) { if (dic[e.SortExpression] == "ASC") { dic[e.SortExpression] = "DESC"; } else { dic[e.SortExpression] = "ASC"; } } else//如果不包含的话就生新创建一个 { //dic.Clear(); dic.Add(e.SortExpression, "ASC"); } sql +=" Order by "+ e.SortExpression + " " + dic[e.SortExpression]; DataPage(sql); } } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { for (int i = 0; i < e.Row.Cells.Count; i++) { if (e.Row.Cells[i].Controls.Count > 0) { LinkButton link = e.Row.Cells[i].Controls[0] as LinkButton; string sortexp = link.CommandArgument; if (ViewState["sortExp"] != null) { Dictionary<string, string> dic = ViewState["sortExp"] as Dictionary<string, string>; if (dic.ContainsKey(sortexp)) { Literal li = new Literal(); if (dic[sortexp] == "ASC") { li.Text = "↑"; } else { li.Text = "↓"; } e.Row.Cells[i].Controls.Add(li); } } } } } //按条件给gridview的行加背景颜色 if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[3].Text == "肖唯哲") { e.Row.BackColor = Color.Red; //根据条件统计当前页的记录数 count++; } } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells.RemoveAt(6); e.Row.Cells.RemoveAt(5); e.Row.Cells.RemoveAt(4); e.Row.Cells.RemoveAt(3); e.Row.Cells.RemoveAt(2); e.Row.Cells.RemoveAt(1); e.Row.Cells[0].ColumnSpan = 8; e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Right; e.Row.Cells[0].Text = string.Format("肖唯哲:{0}", count); } } protected void Button1_Click(object sender, EventArgs e) { string sqlid = string.Empty; foreach (GridViewRow row in this.GridView1.Rows) { CheckBox ck1=row.Cells[0].FindControl("ck1") as CheckBox; if (ck1.Checked == true) { LinkButton link=row.Cells[6].FindControl("linkbtnEdit") as LinkButton; sqlid +=" "+link.CommandArgument + " ,"; } } string sql1 = "delete from T_News where Id in (" + sqlid.TrimEnd(',')+")"; int i= DeleteDatas(sql1); if (i > 0) { ClientScript.RegisterStartupScript(this.GetType(), "key", "alert('删除成功!')", true); DataPage(sql); } } private int DeleteDatas(string sql1) { SqlConnection conn = new SqlConnection(constr); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = sql1; int num = Convert.ToInt32(cmd.ExecuteNonQuery()); return num; conn.Dispose(); } protected void Button2_Click1(object sender, EventArgs e) { //Response.Write("<script type='text/javascript'>showdiv()</script>"); ClientScript.RegisterStartupScript(this.GetType(), "key", "showdiv()", true); } } 。
最后此篇关于对GridView的行加颜色并弹出Kindeditor的实现思路的文章就讲到这里了,如果你想了解更多关于对GridView的行加颜色并弹出Kindeditor的实现思路的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
猫f1.txt阿曼维沙尔阿杰贾伊维杰拉胡尔曼尼什肖比特批评塔夫林现在输出应该符合上面给定的条件 最佳答案 您可以在文件读取循环中设置一个计数器并打印它, 计数=0 读取行时做 让我们数一数++ if
我正在尝试查找文件 1 和文件 2 中的共同行。如果公共(public)行存在,我想写入文件 2 中的行,否则打印文件 1 中的非公共(public)行。fin1 和 fin2 是这里的文件句柄。它读
我有这个 SQL 脚本: CREATE TABLE `table_1` ( `IDTable_1` int(11) NOT NULL, PRIMARY KEY (`IDTable_1`) );
我有 512 行要插入到数据库中。我想知道提交多个插入内容是否比提交一个大插入内容有任何优势。例如 1x 512 行插入 -- INSERT INTO mydb.mytable (id, phonen
如何从用户中选择user_id,SUB(row, row - 1),其中user_id=@userid我的表用户,id 为 1、3、4、10、11、23...(不是++) --id---------u
我曾尝试四处寻找解决此问题的最佳方法,但我找不到此类问题的任何先前示例。 我正在构建一个基于超本地化的互联网购物中心,该区域分为大约 3000 个区域。每个区域包含大约 300 个项目。它们是相似的项
preg_match('|phpVersion = (.*)\n|',$wampConfFileContents,$result); $phpVersion = str_replace('"','',
我正在尝试创建一个正则表达式,使用“搜索并替换全部”删除 200 个 txt 文件的第一行和最后 10 行 我尝试 (\s*^(\h*\S.*)){10} 删除包含的前 10 行空白,但效果不佳。 最
下面的代码从数据库中获取我需要的信息,但没有打印出所有信息。首先,我知道它从表中获取了所有正确的信息,因为我已经在 sql Developer 中尝试过查询。 public static void m
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我试图在两个表中插入记录,但出现异常。您能帮我解决这个问题吗? 首先我尝试了下面的代码。 await _testRepository.InsertAsync(test); await _xyzRepo
这个基本的 bootstrap CSS 显示 1 行 4 列: Text Text Text
如果我想从表中检索前 10 行,我将使用以下代码: SELECT * FROM Persons LIMIT 10 我想知道的是如何检索前 10 个结果之后的 10 个结果。 如果我在下面执行这段代码,
今天我开始使用 JexcelApi 并遇到了这个:当您尝试从特定位置获取元素时,不是像您通常期望的那样使用sheet.getCell(row,col),而是使用sheet.getCell(col,ro
我正在尝试在我的网站上开发一个用户个人资料系统,其中包含用户之前发布的 3 个帖子。我可以让它选择前 3 条记录,但它只会显示其中一条。我是不是因为凌晨 2 点就想编码而变得愚蠢? query($q)
我在互联网上寻找答案,但找不到任何答案。 (我可能问错了?)我有一个看起来像这样的表: 我一直在使用查询: SELECT title, date, SUM(money) FROM payments W
我有以下查询,我想从数据库中获取 100 个项目,但 host_id 多次出现在 urls 表中,我想每个 host_id 从该表中最多获取 10 个唯一行。 select * from urls j
我的数据库表中有超过 500 行具有特定日期。 查询特定日期的行。 select * from msgtable where cdate='18/07/2012' 这将返回 500 行。 如何逐行查询
我想使用 sed 从某一行开始打印 n 行、跳过 n 行、打印 n 行等,直到文本文件结束。例如在第 4 行声明,打印 5-9,跳过 10-14,打印 15-19 等 来自文件 1 2 3 4 5 6
我目前正在执行验证过程来检查用户的旧密码,但问题是我无法理解为什么我的查询返回零行,而预期它有 1 行。另一件事是,即使我不将密码文本转换为 md5,哈希密码仍然得到正确的答案,但我不知道为什么会发生
我是一名优秀的程序员,十分优秀!