📄 default.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.SqlClient;
using RWSB.DatabaseOper;
namespace RWSB
{
/// <summary>
/// list 的摘要说明。
/// </summary>
public partial class list : System.Web.UI.Page
{
public string text;
DatabaseConnect Dbc = new DatabaseConnect();
protected void Page_Load(object sender, System.EventArgs e)
{
//SetDivePage();
// 在此处放置用户代码以初始化页面
if (!this.IsPostBack)
{
//判断用户是否登录
if (Session["UserGrade"] == null)
Session["UserGrade"] = DBOperateSite.GetUserGrade(User.Identity.Name);
Lbl_UserGrade.Text = "用户级别:" + Session["UserGrade"].ToString();
if ((User.Identity.Name == null) || (User.Identity.Name == ""))
{
Lbl_UserName.Text = "当前用户:浏览用户";
}
else
{
Lbl_UserName.Text = "当前用户:" + Session["UserName"];
}
Lbl_UserBmName.Text = "所属部门:" + Session["userbmmc"];
dataBind();
//this.Columnlist1.DataBind();
}
else
{
dataBind();
this.Columnlist1.DataBind();
}
}
protected void BindGridToSource()
{
string sqlstring = "select Top 6 rwid,sbsj,xb,rwxz,zcqj,zyxm,wcsl,zycj,zycjorder from rwxx order by sbsj desc";
string strconn = ConfigurationSettings.AppSettings["conn"];
SqlConnection myconn = new SqlConnection(strconn);
myconn.Open();
SqlDataAdapter mycmd = new SqlDataAdapter(sqlstring, myconn);
DataSet ds = new DataSet();
mycmd.Fill(ds, "rwxx");
dg.DataSource = ds.Tables["rwxx"].DefaultView;
dg.DataBind();
}
/*private void SetDivePage()
{
dg.AllowPaging = true;
dg.PageSize = 10;
ZHENGYI.BindDataDelegate f = new ZHENGYI.BindDataDelegate(dataBind);
divepage.SetTarget(dg, f, 15);
}*/
private void dataBind()
{
BindGridToSource();
}
private void dg_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.Item.Cells[3].Text.Length > 40)
{
e.Item.Cells[3].Text = "<a href=\"#\" onclick=\"openwin('" + e.Item.Cells[0].Text + "')\" title=\"" + e.Item.Cells[3].Text + "\">" + e.Item.Cells[3].Text.Substring(0, 40) + "...</a>";
}
else
{
e.Item.Cells[3].Text = "<a href=\"#\" onclick=\"openwin('" + e.Item.Cells[0].Text + "')\" title=\"" + e.Item.Cells[3].Text + "\">" + e.Item.Cells[3].Text + "</a>";
}
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.dg.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dg_ItemDataBound);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -