📄 dispresultform.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;
namespace BookersClient
{
/// <summary>
/// Summary description for WebForm3.
/// </summary>
public class WebForm3 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblInfo;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
DTService.Service1 srv1 = new DTService.Service1();
DataSet ds1;
string strCategory;
string strParam;
strCategory = Request.QueryString.Get(0).ToString();
strParam = Request.QueryString.Get(1).ToString();
switch(strCategory)
{
case "ALL":
ds1 = srv1.SearchALL();
if(ds1.Tables["Details"].Rows.Count != 0)
{
DataView source= new DataView(ds1.Tables["Details"]);
DataGrid1.DataSource=source;
DataGrid1.DataBind();
lblInfo.Text = "Your search produced following results...";
}
else
{
DataGrid1.Visible = false;
lblInfo.Text = "No matching records found!!";
}
break;
case "Title":
ds1=srv1.SrchTitle (strParam);
if(ds1.Tables["Details"].Rows.Count !=0)
{
DataView source= new DataView(ds1.Tables["Details"]);
DataGrid1.DataSource=source;
DataGrid1.DataBind();
lblInfo.Text = "Your search produced following results...";
}
else
{
DataGrid1.Visible = false;
lblInfo.Text = "No matching records found!!";
}
break;
case "ISBN Number":
ds1=srv1.SrchISBN (strParam);
if(ds1.Tables["Details"].Rows.Count !=0)
{
DataView source= new DataView(ds1.Tables["Details"]);
DataGrid1.DataSource=source;
DataGrid1.DataBind();
lblInfo.Text = "Your search produced following results...";
}
else
{
DataGrid1.Visible = false;
lblInfo.Text = "No matching records found!!";
}
break;
case "Author":
ds1=srv1.SrchAuthor (strParam);
if(ds1.Tables["Details"].Rows.Count !=0)
{
DataView source= new DataView(ds1.Tables["Details"]);
DataGrid1.DataSource=source;
DataGrid1.DataBind();
lblInfo.Text = "Your search produced following results...";
}
else
{
DataGrid1.Visible = false;
lblInfo.Text = "No matching records found!!";
}
break;
case "Category":
ds1=srv1.SrchCategory(strParam);
if(ds1.Tables["Details"].Rows.Count !=0)
{
DataView source= new DataView(ds1.Tables["Details"]);
DataGrid1.DataSource=source;
DataGrid1.DataBind();
lblInfo.Text = "Your search produced following results...";
}
else
{
DataGrid1.Visible = false;
lblInfo.Text = "No matching records found!!";
}
break;
default:
break;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand);
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName == "Ord")
{
string strISBN;
string strTitle;
string strAuthor;
strISBN = e.Item.Cells[1].Text ;
strTitle = e.Item.Cells[2].Text ;
strAuthor = e.Item.Cells[3].Text;
Response.Redirect ("OrdersForm.aspx?ISBN=" + strISBN + " & Title=" + strTitle + " & Author=" + strAuthor);
}
}
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -