?? 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 + -