📄 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 BookManage.BLL;
using BookManage.Model;
/// <summary>
/// _Default 的摘要说明。
/// </summary>
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
filterType.AutoBindData();
}
txtSearch.Attributes.Add("onkeydown", "if(event.keyCode==13){document.getElementById('" + btnSearch.ClientID + "').focus();document.getElementById('" + btnSearch.ClientID + "').click();}");
BindData();
}
protected void btnSearch_ServerClick(object sender, EventArgs e)
{
ViewState.Add("search", "search");
ViewState.Remove("type");
BindData();
}
protected void bookList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
BookInfo bookInfo = (BookInfo)e.Row.DataItem;
if (bookInfo.BookStatus == false)
e.Row.Cells[4].Text = "未借出";
else
e.Row.Cells[4].Text = "已借出";
}
}
protected void filterType_SelectedIndexChanged(object sender, EventArgs e)
{
ViewState.Add("type", "type");
ViewState.Remove("search");
BindData();
}
void BindData()
{
if (ViewState["search"] == null && ViewState["type"] == null)
{
bookList.DataSource = Book.GetBookList();
bookList.DataBind();
}
else if (ViewState["search"] != null)
{
bookList.DataSource = Book.GetBookListByName(txtSearch.Value);
bookList.DataBind();
}
else if (ViewState["type"] != null)
{
if (filterType.SelectedIndex == 0)
bookList.DataSource = Book.GetBookList();
else
{
int typeId = int.Parse(filterType.SelectedValue);
bookList.DataSource = Book.GetBookListByType(typeId);
}
bookList.DataBind();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -