你的DataGrid 的DataBind()方法不要放在if(!Page.IsPostBack){}中,放在外面!
解决方案 »
- 行如何添加列
- 安装Visual C# 2005 Express Edtion后。。。。。。
- 帮帮小妹我的问题啊:Checkbox 在datalist中的问题。
- 怎么在datagrid模版列里,如<%# DataBinder.Eval(Container.DataItem, "Prdt_code") %>邦定数据,如果该字段为空,则显示字符串“无”,
- .NET验证控件是在客户端验证还是在服务器端验证?
- 未能加载文件或程序集“DevExpress.Data.v10.2”或它的某一个依赖项。未能验证强名称签名。此程序集可能已被篡改,或者已被延迟签名,但没有用正确的
- .net怎么搭建团队项目(TFS)
- 一个关于检索出数据的筛选的问题
- dataSet的table里面怎么下移一条数据?
- 现在发现JSP的空间比ASP/ASP.NET的空间还贵是为什么啊?谢谢
- 奇怪现象:我的datagrid为什么只对当前页排序呢,真是个奇怪的问题,大家能帮我分析一下是什么原因吗>
- 思归大哥,再问一个问题。
if(!Page.IsPostBack)
{
....
bindDB();
}
改为:
if(!Page.IsPostBack)
{
bindDB();
}
bindDB();
应该改为: DGnews.CurrentPageIndex=e.NewPageIndex;
DGnews.DataBind();
OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("./") + "test.mdb");
OleDbCommand cmd=new OleDbCommand("select newsid,title from news order by newsid desc",conn);
conn.Open();
DataSet DS=new DataSet();
OleDbDataAdapter DA=new OleDbDataAdapter();
DA.SelectCommand=cmd;
DA.Fill(DS,"newsid");
DGnews.DataSource=DS.Tables[0].DefaultView;
DGnews.CurrentPageIndex = e.NewPageIndex;
DGnews.DataBind();
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
bindDB();
}
}
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
bindDB();
}
}
void bindDB()
{
OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("./") + "test.mdb");
OleDbCommand cmd=new OleDbCommand("select newsid,title from news order by newsid desc",conn);
conn.Open();
DataSet DS=new DataSet();
OleDbDataAdapter DA=new OleDbDataAdapter();
DA.SelectCommand=cmd;
DA.Fill(DS,"newsid");
DGnews.DataSource=DS.Tables[0].DefaultView;
DGnews.DataBind();
conn.Close();
}
public void DGPageIndex_Changed(Object sender, DataGridPageChangedEventArgs e) {
DGnews.CurrentPageIndex = e.NewPageIndex;
bindDB();
}