为什么我的分页没有生效???
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<script runat="server">
SqlConnection Con = new SqlConnection(ConfigurationSettings.AppSettings["stringConnection"]);
SqlCommand Cmd = new SqlCommand();
void Page_Load(Object source,EventArgs e)
{
if(!IsPostBack)
{
BindData();
}
}
void BindData()
{
string strShowMessage = "SELECT * FROM t_message ORDER BY f_date DESC";
Cmd.CommandText = strShowMessage;
Cmd.Connection = Con;
SqlDataReader sdrShow;
Con.Open();
sdrShow = Cmd.ExecuteReader();
xxx.DataSource = sdrShow;
xxx.DataBind();
Con.Close();
sdrShow.Close();
}
protected void vvv(Object source,DataGridPageChangedEventArgs e)
{
xxx.CurrentPageIndex = e.NewPageIndex;
BindData();
}
</script>
<body>
<asp:datagrid AllowCustomPaging="true" AllowPaging="true" AutoGenerateColumns="true" ID="xxx" runat="server" OnPageIndexChanged="vvv" PageSize="5"></asp:datagrid>
</body>
</html>