只能显示5行以下的记录,而且不能翻页.
在属性生成器里设置过,没有用.
请教是什么出的问题.
private void Binding()
{
string connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+MapPath("Aspnet.mdb")+";";
OleDbConnection Conn=new OleDbConnection(connstr);
string strCom;
strCom="SELECT PostID,Subject,UserInfo.UserName,Newpost.RegTime,Newpost.WebSite,Email FROM Newpost,UserInfo where Newpost.UserName=UserInfo.UserName ORDER BY Newpost.RegTime DESC";
OleDbCommand formCommand=new OleDbCommand(strCom,Conn);
Conn.Open();
OleDbDataReader formReader=formCommand.ExecuteReader();
DG.DataSource=formReader;
DG.DataBind();
Conn.Close();
}
private void DG_DeleteCommand_1(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string thisID=DG.DataKeys[e.Item.ItemIndex].ToString();
string connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+MapPath("Aspnet.mdb")+";";
OleDbConnection Conn=new OleDbConnection(connstr);
Conn.Open();
string deletestring="delete from Newpost where PostID="+thisID+"";
OleDbCommand sc=new OleDbCommand(deletestring,Conn);
sc.ExecuteNonQuery();
Conn.Close();
Conn.Dispose();
sc.Dispose();
Binding();
}
private void DG_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DG.CurrentPageIndex=e.NewPageIndex;
Binding();
}