asp.net 要实现页面预览 数据库是sql server2000 用的是存储过程 菜鸟最近写了个页面想实现页面预览,数据库用的是sql server2000,在数据库下写的是存储过程,但是不知道怎样实现页面的预览,求高手指点,最好有例子,或代码,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以把数据先存在viewstate中。 但是哪位高手没说清楚具体是怎样在viewstate下怎样实现啊,郁闷,, 下面是用viewstate保存datagrid排序值using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Data.SqlClient;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 HeFengSMS.MainPage{ /// <summary> /// MainOnlineShow 的摘要说明。 /// </summary> public class MainOnlineShow : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid dgrd_OnlinePerson; //存放页眉文字 private string[] headtext; private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { headtext = new String[dgrd_OnlinePerson.Columns.Count]; for(int i=0;i<dgrd_OnlinePerson.Columns.Count;i++) { headtext[i] = dgrd_OnlinePerson.Columns[i].HeaderText; } ViewState["headtext"] = headtext; ViewState["SortField"] = "PersonName"; ViewState["SortDirect"] = "ASC"; Bind(); } else { //把页眉复位 headtext = (string[]) ViewState["headtext"]; for(int i=0;i<dgrd_OnlinePerson.Columns.Count;i++) { dgrd_OnlinePerson.Columns[i].HeaderText = headtext[i]; } } } private void Bind() { HeFengSMS.Components.Persons ps = new HeFengSMS.Components.Persons(); SqlDataReader dr = ps.GetOnlinePerson(); DataTable dt = ps.ConvertDataReaderToDataTable(dr); dt.DefaultView.Sort = ViewState["SortField"] + " " + ViewState["SortDirect"]; dgrd_OnlinePerson.DataSource = dt.DefaultView; dgrd_OnlinePerson.DataBind(); } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.dgrd_OnlinePerson.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.dgrd_OnlinePerson_SortCommand); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void dgrd_OnlinePerson_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e) { if(ViewState["SortField"].ToString() == e.SortExpression) { ViewState["SortDirect"] = (ViewState["SortDirect"].ToString()=="ASC")?"DESC":"ASC"; } else { ViewState["SortField"] = e.SortExpression; ViewState["SortDirect"] = "ASC"; } foreach(DataGridColumn col in dgrd_OnlinePerson.Columns) { if(col.SortExpression.ToString()==ViewState["SortField"].ToString()) { if(ViewState["SortDirect"].ToString() == "ASC") col.HeaderText += "<img src='../images/asc.gif' border=0/>"; else col.HeaderText += "<img src='../images/desc.gif' border=0/>"; } } Bind(); } }} 谢谢,如果我用的控件不是datagrid,而是textbox也可以这样吗? http://blog.csdn.net/Truly/archive/2005/05/27/382444.aspx把这个页面中的textbox的值在下个页面接受并显示出来即可 在dal层的方法中加上IDbTransaction 参数可行吗 fckeditor不能插入图片(上传正常)???? 做毕业设计了,想找篇外文,大家给点建议。 深圳的ASP.NET程序员都进来看看! 关于中文的字母排序问题。 如何获取结果集中指定例的值? 為什麼treeview樹型結構在瀏覽器中不能正常顯示 请教诸位关于inStr比较字符串的用法 中文asp.net下编的日文代码程序 拿到日文下面看代码 显示乱码 页面乱码与404 急啊...HELP ME 根据在孟子<DataGrid快速添加新行>的方法,Footer Template里面有个DropDownList绑定数据出问题.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
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 HeFengSMS.MainPage
{
/// <summary>
/// MainOnlineShow 的摘要说明。
/// </summary>
public class MainOnlineShow : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid dgrd_OnlinePerson;
//存放页眉文字
private string[] headtext;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
headtext = new String[dgrd_OnlinePerson.Columns.Count];
for(int i=0;i<dgrd_OnlinePerson.Columns.Count;i++)
{
headtext[i] = dgrd_OnlinePerson.Columns[i].HeaderText;
}
ViewState["headtext"] = headtext; ViewState["SortField"] = "PersonName";
ViewState["SortDirect"] = "ASC";
Bind();
}
else
{
//把页眉复位
headtext = (string[]) ViewState["headtext"];
for(int i=0;i<dgrd_OnlinePerson.Columns.Count;i++)
{
dgrd_OnlinePerson.Columns[i].HeaderText = headtext[i];
} }
}
private void Bind()
{
HeFengSMS.Components.Persons ps = new HeFengSMS.Components.Persons();
SqlDataReader dr = ps.GetOnlinePerson();
DataTable dt = ps.ConvertDataReaderToDataTable(dr);
dt.DefaultView.Sort = ViewState["SortField"] + " " + ViewState["SortDirect"];
dgrd_OnlinePerson.DataSource = dt.DefaultView;
dgrd_OnlinePerson.DataBind();
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.dgrd_OnlinePerson.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.dgrd_OnlinePerson_SortCommand);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void dgrd_OnlinePerson_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
if(ViewState["SortField"].ToString() == e.SortExpression)
{
ViewState["SortDirect"] = (ViewState["SortDirect"].ToString()=="ASC")?"DESC":"ASC";
}
else
{
ViewState["SortField"] = e.SortExpression;
ViewState["SortDirect"] = "ASC"; }
foreach(DataGridColumn col in dgrd_OnlinePerson.Columns)
{
if(col.SortExpression.ToString()==ViewState["SortField"].ToString())
{
if(ViewState["SortDirect"].ToString() == "ASC")
col.HeaderText += "<img src='../images/asc.gif' border=0/>";
else
col.HeaderText += "<img src='../images/desc.gif' border=0/>";
}
} Bind();
}
}
}
如果我用的控件不是datagrid,而是textbox也可以这样吗?
把这个页面中的textbox的值在下个页面接受并显示出来即可