gridview 设置允许分页,允许排序.然后绑定到dataset,如下:this.gvList.DataSource = log.getDS;
this.gvList.DataBind();但是我在点分页和排序的时候,都报错,说要我写相应的排序和分页事件,我记得这些功能不用写事件代码的,是不是我的 vs2005是试用版的原因?
this.gvList.DataBind();但是我在点分页和排序的时候,都报错,说要我写相应的排序和分页事件,我记得这些功能不用写事件代码的,是不是我的 vs2005是试用版的原因?
解决方案 »
- .net 获得网关ip
- 传值问题
- 你做的软件你是在用“心”在做吗?
- 将TextBox中的内容写入数据库时出错
- 真郁闷,win2003,随便建一个项目都提示: 找不到文件或程序集名称“URLRewriter”,或找不到它的一个依赖项
- 简单的图像显示问题.
- 求大虾解答.~~~送分70,+刚才那张帖子的30.搞定后,一起结了.
- 问高手一个问题,悬赏150分@!!!!!!!!!!!!!!!!!!!!!!!!
- 各位大侠,快帮忙呀!(在线等待,急,马上给分)
- create XmlDocument-object from a Xml-string
- 在 vs2005 运行一切正常 但是到iis 下就是提示用户 'IVAN\ASPNET' 登录失败。
- 生成静态页面的新闻系统,是不是只要在后台发一篇新闻,就要更新一次首页 和 所有的栏目首页 和分页。
只不过查询,删除,修改都要写代码。
我用的SQLServer2005 EXPRESS,VS.NET2005
1。
确定+肯定告诉你不是VS05的问题2。
"所谓不用写事件代码"
asp.net 2.0 是指使用数据源控件(如SqlDataSource )自动绑定数据的那种形式,
1.x 是托拽 DataSet 以及 xxxDataAdapter 自动绑定的3.
按你这样写法,就是手动绑定,你需要实现相关的事件处理程序,如<%@ Page language="C#" %><script runat="server">
void CustomersGridView_DataBound(Object sender, EventArgs e)
{
if (!IsPostBack)
{
// Call a helper method to display the current page number
// when the page is first loaded.
DisplayCurrentPage();
}
} void CustomersGridView_PageIndexChanged(Object sender, EventArgs e)
{
// Call a helper method to display the current page number
// when the user navigates to a different page.
DisplayCurrentPage();
} void DisplayCurrentPage()
{
// Calculate the current page number.
int currentPage = CustomersGridView.PageIndex + 1; // Display the current page number.
Message.Text = "Page " + currentPage.ToString() + " of " +
CustomersGridView.PageCount.ToString() + ".";
}</script><html>
<body>
<form runat="server">
<h3>GridView PageIndexChanged Example</h3>
<asp:label id="Message"
forecolor="Red"
runat="server"/>
<br/> <asp:gridview id="CustomersGridView"
datasourceid="CustomersSource"
autogeneratecolumns="true"
emptydatatext="No data available."
allowpaging="true"
ondatabound="CustomersGridView_DataBound"
onpageindexchanged="CustomersGridView_PageIndexChanged"
runat="server">
<pagersettings mode="Numeric"
position="Bottom"
pagebuttoncount="10"/>
<pagerstyle backcolor="LightBlue"/>
</asp:gridview>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:sqldatasource id="CustomersSource"
selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html> }其他详细信息请参考:
http://msdn2.microsoft.com/zh-cn/library/system.web.ui.webcontrols.gridview_events(vs.80).aspx
http://msdn2.microsoft.com/zh-cn/library/system.web.ui.webcontrols.gridview.pageindexchanged(vs.80).aspxGood luck!
<asp:gridview id="GridView"
autogeneratecolumns="true"
emptydatatext="No data available."
allowpaging="true"
onpageindexchanging="GridView1_PageIndexChanging"
runat="server">
<pagersettings mode="Numeric"
position="Bottom"
pagebuttoncount="10"/>
<pagerstyle backcolor="LightBlue"/>
</asp:gridview>
// .aspx.csprotected void GridView1_PageIndexChanging(Object sender, GridViewPageEventArgs e)
{
GridView grd = sender as GridView;
grd.PageIndex = e.NewPageIndex;
// rebind
BindGridView();
}void BindGridView()
{
GridView1.DataSource = GetMyDataSource();
GridView1.DataBind();
}
{
GridView1.PageIndex = e.NewPageIndex;
BindData();
}
void BindData()
{
GridView1.DataSource = 绑定数据源;
GridView1.DataBind();
}