留言簿
2005/6/14 3:46:00 cui
你好,我用三层结构使用您的分页控件,数据可以正常显示,但分页控件无法帮定,限制每页显示数量却好用。
以下是我帮定数据时的代码,如下,请多指教!
private void BindData()
{
DataTable articleList = Business.Article.ArticleNetPager(161,PagerList.CurrentPageIndex,PagerList.PageSize,false);
ArticleList.DataSource = articleList.DefaultView;
ArticleList.DataBind();
}
商务层:
public static DataTable ArticleNetPager(int pageindex, int pagesize,bool docount)
{
Configuration.ModuleSettings settings = Configuration.ModuleConfig.GetSettings();
Data.Article article = new Data.Article(settings.ConnectionString);
return article.ArticleNetPager(pageindex,pagesize,docount);
}
数据层:
public DataTable ArticleNetPager(int ClassID,int pageindex, int pagesize,bool docount)
{
SqlParameter[] parameters = {
new SqlParameter("@pageindex", SqlDbType.Int, 4),
new SqlParameter("@pagesize", SqlDbType.Int, 4),
new SqlParameter("@docount", SqlDbType.Bit, 1)
};
parameters[1].Value = ClassID;
parameters[2].Value = pageindex;
parameters[3].Value = pagesize;
using(DataSet article = RunProcedure("Article_NetPager", parameters, "ArticleNetPager"))
{
return article.Tables[0];
}
}
数据可以正常显示
多谢多谢!
以下是我帮定数据时的代码,如下,请多指教!
private void BindData()
{
DataTable articleList = Business.Article.ArticleNetPager(161,PagerList.CurrentPageIndex,PagerList.PageSize,false);
ArticleList.DataSource = articleList.DefaultView;
ArticleList.DataBind();
}
商务层:
public static DataTable ArticleNetPager(int pageindex, int pagesize,bool docount)
{
Configuration.ModuleSettings settings = Configuration.ModuleConfig.GetSettings();
Data.Article article = new Data.Article(settings.ConnectionString);
return article.ArticleNetPager(pageindex,pagesize,docount);
}
数据层:
public DataTable ArticleNetPager(int ClassID,int pageindex, int pagesize,bool docount)
{
SqlParameter[] parameters = {
new SqlParameter("@pageindex", SqlDbType.Int, 4),
new SqlParameter("@pagesize", SqlDbType.Int, 4),
new SqlParameter("@docount", SqlDbType.Bit, 1)
};
parameters[1].Value = ClassID;
parameters[2].Value = pageindex;
parameters[3].Value = pagesize;
using(DataSet article = RunProcedure("Article_NetPager", parameters, "ArticleNetPager"))
{
return article.Tables[0];
}
}
数据可以正常显示
多谢多谢!
回复:您好,我没有理解您的意思,AspNetPager分页控件不需要绑定任何数据,只要设置RecordCount和指定PageChanged事件处理程序即可,不知道您说的绑定是怎么回事?谢谢!
2005/6/13 16:59:00 datagrid
你好:下面的代码编译时出错,(错误信息:不能在此范围内声明名为“i”的局部变量,因为这样会使“i”具有不同的含义,而它已经用于“父级或当前”范围以表示其他内容。
“System.Web.UI.WebControls.TableRow.Cells”表示“属性”,此处应为“方法”)该怎么改?谢谢
public void dg_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType = ListItemType.Header){
if((true)){
int i;
for (int i = 0; i <= e.Item.Cells.Count - 1; i++)
{
e.Item.Cells(i).Attributes.Add("onmousemove", "SyDG_moveOnTd(this)");
e.Item.Cells(i).Attributes.Add("onmousedown", "SyDG_downOnTd(this)");
e.Item.Cells(i).Attributes.Add("onmouseup", "this.mouseDown=false");
e.Item.Cells(i).Attributes.Add("onmouseout", "this.mouseDown=false");
}
}
}
“System.Web.UI.WebControls.TableRow.Cells”表示“属性”,此处应为“方法”)该怎么改?谢谢
public void dg_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType = ListItemType.Header){
if((true)){
int i;
for (int i = 0; i <= e.Item.Cells.Count - 1; i++)
{
e.Item.Cells(i).Attributes.Add("onmousemove", "SyDG_moveOnTd(this)");
e.Item.Cells(i).Attributes.Add("onmousedown", "SyDG_downOnTd(this)");
e.Item.Cells(i).Attributes.Add("onmouseup", "this.mouseDown=false");
e.Item.Cells(i).Attributes.Add("onmouseout", "this.mouseDown=false");
}
}
}
回复:您好,for循环前已经定义了一个int i变量,for循环中不应该再重新定义一个int i,把for循环中的int i中的int去掉就应该可以了。谢谢!
2005/6/13 14:01:00 DW
大哥您好:
发现你的的分页控件有个小小的缺点: "不支持自定义的URL"
例如: 当前页面是"http://www.webdiyer.com/guestbook/Default.aspx?page=2"
我希望自定义成
http://www.webdiyer.com/guestbook/Default.html?page=2
或 http://www.webdiyer.com/guestbook/Default?page=2
不知可否支持? 因为这样做可以提高Google的收录率.
谢谢!!!
发现你的的分页控件有个小小的缺点: "不支持自定义的URL"
例如: 当前页面是"http://www.webdiyer.com/guestbook/Default.aspx?page=2"
我希望自定义成
http://www.webdiyer.com/guestbook/Default.html?page=2
或 http://www.webdiyer.com/guestbook/Default?page=2
不知可否支持? 因为这样做可以提高Google的收录率.
谢谢!!!
回复:您好,AspNetPager是不支持这样的功能,但向上面说的把aspx后缀名去掉或改为html和google的收录率应该没有任何关系,google不会只收录html页面而忽略aspx文件。谢谢!
2005/6/12 11:02:00 溜达
我给你发了个mail。是那个窗体的代码dgxx.aspx.cs。能帮我看看吗?编译,执行都可以。代码会不会有点乱?谢谢!
回复:您好,只有一个cs文件,我无法运行调试,所以无法看出来是什么错误。谢谢!
2005/6/12 10:11:00 溜达
是服务器端程序错误.Unspecified System Error = -21000. 搞不明白
2005/6/11 6:53:00 溜达
楼下的溜达
那个查询的窗体编译通过的,执行也成功的。就是翻的时候有些页会出错,会不会和日期选择控件的
Default.css样式表有关系?
那个查询的窗体编译通过的,执行也成功的。就是翻的时候有些页会出错,会不会和日期选择控件的
Default.css样式表有关系?
回复:什么样的错误呢?是客户端脚本错误还是服务器端程序错误?如果是服务器端程序错误那和样式表毫无关系。谢谢!
2005/6/10 16:47:00 那一刀的风流
您好,我得问题已经解决,是一开始测试时的代码很乱,留下了一些干扰的代码,删除后可以正常使用了,谢谢您的辛苦工作给我们带来方便
回复:不用客气,谢谢使用AspNetPager!
2005/6/10 16:34:00 那一刀的风流
看到上次留言显示混乱
您到这里看看吧
http://www.51js.com/viewthread.php?tid=39195&pid=351677&page=1&sid=H06744#pid351677
您到这里看看吧
http://www.51js.com/viewthread.php?tid=39195&pid=351677&page=1&sid=H06744#pid351677
2005/6/10 16:16:00 那一刀的风流
我想用作datalist的分页,但是不显示控件,数据库表里面有超过60行的数据
您看代码哪里错了
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Call mydatabind()
End If
End Sub
Private Sub AspNetPager1_PageChanged(ByVal src As System.Object, ByVal e As Wuqi.Webdiyer.PageChangedEventArgs) Handles AspNetPager1.PageChanged
AspNetPager1.CurrentPageIndex = e.NewPageIndex
Call mydatabind()
End Sub
Sub mydatabind()
Dim strconn, sql As String
Dim objconn As SqlConnection
Dim objcmd As SqlCommand
Dim objcmd1 As SqlDataAdapter
Dim objreader As SqlDataReader
Dim ds As DataSet = New DataSet
strconn = ConfigurationSettings.AppSettings("strconn")
objconn = New SqlConnection
objconn.ConnectionString = strconn
objconn.Open()
objcmd = New SqlCommand
objcmd.Connection = objconn
objcmd.CommandText = "select count(id) from subject where forum='" & Request.QueryString("forum") & "' and sort1='" & Request.QueryString("sort1") & "'"
Dim totalcount As Integer
totalcount = objcmd.ExecuteScalar
AspNetPager1.RecordCount = totalcount
AspNetPager1.PageSize = 30
objcmd.CommandText = "select id,title,start_time,teacher,city,price,hit from subject where forum='" & Request.QueryString("forum") & "' and sort1='" & Request.QueryString("sort1") & "'"
objcmd1 = New SqlDataAdapter(objcmd)
objcmd1.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "subject")
AspNetPager1.RecordCount = ds.Tables("subject").DefaultView.Count
AspNetPager1.CustomInfoText = "记录总数:" & AspNetPager1
您看代码哪里错了
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Call mydatabind()
End If
End Sub
Private Sub AspNetPager1_PageChanged(ByVal src As System.Object, ByVal e As Wuqi.Webdiyer.PageChangedEventArgs) Handles AspNetPager1.PageChanged
AspNetPager1.CurrentPageIndex = e.NewPageIndex
Call mydatabind()
End Sub
Sub mydatabind()
Dim strconn, sql As String
Dim objconn As SqlConnection
Dim objcmd As SqlCommand
Dim objcmd1 As SqlDataAdapter
Dim objreader As SqlDataReader
Dim ds As DataSet = New DataSet
strconn = ConfigurationSettings.AppSettings("strconn")
objconn = New SqlConnection
objconn.ConnectionString = strconn
objconn.Open()
objcmd = New SqlCommand
objcmd.Connection = objconn
objcmd.CommandText = "select count(id) from subject where forum='" & Request.QueryString("forum") & "' and sort1='" & Request.QueryString("sort1") & "'"
Dim totalcount As Integer
totalcount = objcmd.ExecuteScalar
AspNetPager1.RecordCount = totalcount
AspNetPager1.PageSize = 30
objcmd.CommandText = "select id,title,start_time,teacher,city,price,hit from subject where forum='" & Request.QueryString("forum") & "' and sort1='" & Request.QueryString("sort1") & "'"
objcmd1 = New SqlDataAdapter(objcmd)
objcmd1.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "subject")
AspNetPager1.RecordCount = ds.Tables("subject").DefaultView.Count
AspNetPager1.CustomInfoText = "记录总数:" & AspNetPager1
2005/6/10 16:04:00 Lee
楼下的Lee,那个表的问题,我弄好了。谢谢!
回复:好!这两天回家探亲没有上班,没有及时回复请原谅。
