关于ASP.net与AJAX用gridview进实现无刷新并分页随笔
开发环境:WIN XP VS2005
数据库:SQL server 2000
此处不考虑安全问题.
具体如下:
首先建立一个数据库和一个表结构并在表中输入一些数据以便测试:此步略过
打开VS2005新建一个网站并添加一个HTML页
在默认的Default.aspx中放入Gridview控件用于显示数据
.cs代码
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;
public partial class _Default : System.Web.UI.Page
{
public int j = 0;
protected void Page_Load(object sender, EventArgs e)
{
databind();
}
/// <summary>
/// 分页
/// </summary>
private void databind()
{
string connStrings = ConfigurationManager.ConnectionStrings["WSConStringSQL"].ToString();
SqlConnection sqlconn = new SqlConnection(connStrings);
SqlCommand sqlcom = new SqlCommand("Select * from TB_AdminUser ", sqlconn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(sqlcom);
da.Fill(ds);
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 5;
int CurPage;
&
相关文档:
原文:刘武|在asp.net webservice中如何使用session
在使用asp.net编写webservice时,默认情况下是不支持session的,但我们可以把WebMethod的EnableSession选项设为true来显式的打开它,请看以下例子:
1 新建网站WebSite
2 新建web服务WebService.asmx,它具有以下两个方法:
C#-Code:
[WebMe ......
ASP.NET Literal控件用法_华为金山网
在您要以编程方式设置文本而不添加额外的 HTML 标记时,可以向页面添加 Literal Web 服务器控件。在要向页面动态添加文本而不添加任何不属于该动态文本的元素时,Literal 控件非常有用。例如,您可以使用 Literal 控件来显示从文件或流中读取的 HTML。
注意
如果要显示静态文本, ......
<input id = " loFile " type = " file " runat = " server " >
<form method = " post " enctype =" multipart/form-data " runat = " server ">
</form >
1.获得上传文件的名称:(关键是PostedFile类的应用)
使用Path类中的GetFileName方法,具体如下:
lstrFileName = loFile.PostedFile.FileName
......
///<summary>
///<author>飞鹰@ASPCool.com</author>
///<description>本文用asp.net实现把此文推荐给好友的功能。</desciption>
///<copyright>ASP酷技术资讯网(www.ASPCool.com)</copyright>
///</summary ......