viewcomment.aspx.cs

来自「《精通ASP.NET2.0网络应用系统开发》书中的源码」· CS 代码 · 共 67 行

CS
67
字号
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;
using System.Data.SqlClient;
using BookShop;

public partial class ViewComment : System.Web.UI.Page
{
	private int nCommentID = -1;
	private int nCategoryID = -1;

	protected void Page_Load(object sender, EventArgs e)
	{
		if (Request.Params["CategoryID"] != null)
		{
			nCategoryID = Int32.Parse(Request.Params["CategoryID"].ToString());
		}
		if (Request.Params["CommentID"] != null)
		{
			nCommentID = Int32.Parse(Request.Params["CommentID"].ToString());
		}
		if (!Page.IsPostBack)
		{
			if (nCommentID > -1)
			{
				///显示被修改书籍的数据
				BindCommentData(nCommentID);
			}
		}
	}

	private void BindCommentData(int nCommentID)
	{
		///从数据库获取数据
		Comment comment = new Comment();
		SqlDataReader recc = comment.GetSingleComment(nCommentID);

		///显示数据
		if (recc.Read())
		{
			Desn.Text = recc["Desn"].ToString();
			Body.Text = recc["Body"].ToString();
			CreateDate.Text = recc["CreateDate"].ToString();

			///设置评论所属的书籍
			ASPNET2System.SetListBoxItem(BookList,recc["BookID"].ToString());
			
		}
		///关闭数据源
		recc.Close();
	}

	protected void ReturnBtn_Click(object sender,EventArgs e)
	{
		///返回管理页面
		Response.Redirect("~/DesktopModules/Book/CommentManage.aspx"
			+ "?CategoryID=" + nCategoryID.ToString());
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?