📄 list.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class manage_list : System.Web.UI.Page
{
BaseClass bc = new BaseClass();
static string strStyle;
static int pagecount = 0;
protected void Page_Load(object sender, EventArgs e)
{
int n = Convert.ToInt16(Request.QueryString["id"]);
switch (n)
{
case 1: strStyle = "style='时政要闻'";
break;
case 2: strStyle = "style='经济动向'";
break;
case 3: strStyle = "style='世界军事'";
break;
case 4: strStyle = "style='科学教育'";
break;
case 5: strStyle = "style='法治道德'";
break;
case 6: strStyle = "style='社会现象'";
break;
case 7: strStyle = "style='体育世界'";
break;
case 8: strStyle = "style='时尚娱乐'";
break;
default: strStyle = "style like '%%'";
break;
}
GridView1.DataSource = bc.GetDataSet("select * from tbNews where " + strStyle + "order by id", "tbNews");
GridView1.DataKeyNames = new string[] { "id" };
GridView1.DataBind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
bc.ExecSQL("delete from tbNews where id='" + this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'");
GridView1.DataSource = bc.GetDataSet("select * from tbNews where " + strStyle, "tbNews");
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
protected void cmdSearch_Click(object sender, EventArgs e)
{
string strSql = "select * from tbnews where style='" + DropDownList1.Text + "' and content like '%" + TextBox1.Text + "%'";
GridView1.DataSource = bc.GetDataSet(strSql, "tbNews");
GridView1.DataKeyNames = new string[] { "id" };
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[3].Text =Convert.ToDateTime(e.Row.Cells[3].Text).ToShortDateString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -