public void BindGrid()
{
string sql = "select id,姓名,性别,工作时间,身份证号,学历,职称,岗位 from employee";
SqlDataAdapter da =new SqlDataAdapter(sql,conn);
DataSet userInfo = new DataSet(); da.Fill(userInfo); DataGrid1.DataSource=userInfo.Tables[0].DefaultView ;
DataGrid1.DataBind();
} private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here if(!IsPostBack)
{
BindGrid();
}
ShowStats();
} private void ShowStats()
{
lblCurrentIndex.Text = "第 " + (DataGrid1.CurrentPageIndex + 1).ToString() + " 页";
lblPageCount.Text = "共 " + DataGrid1.PageCount.ToString() + " 页";
}有100多条记录,每页10条,分页功能都是true,但算出的总页数总是为1,是怎么回事?
{
string sql = "select id,姓名,性别,工作时间,身份证号,学历,职称,岗位 from employee";
SqlDataAdapter da =new SqlDataAdapter(sql,conn);
DataSet userInfo = new DataSet(); da.Fill(userInfo); DataGrid1.DataSource=userInfo.Tables[0].DefaultView ;
DataGrid1.DataBind();
} private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here if(!IsPostBack)
{
BindGrid();
}
ShowStats();
} private void ShowStats()
{
lblCurrentIndex.Text = "第 " + (DataGrid1.CurrentPageIndex + 1).ToString() + " 页";
lblPageCount.Text = "共 " + DataGrid1.PageCount.ToString() + " 页";
}有100多条记录,每页10条,分页功能都是true,但算出的总页数总是为1,是怎么回事?
解决方案 »
- asp.net textbox与js截取值问题
- 页面自定义拖拽布局问题的实现
- 能推荐一下asp.net方面好的书籍吗
- 稳定的工作环境与合伙开公司,选择哪一个?
- ora-12154:TNS无法处理服务名(和以往不同)
- 在JavaScript中,如何将中文(gb2312)转成UTF8呀。
- 哪里可以找到ASP.NET中的控件的使用方法,就象JAVA中的帮助文档一样!
- 用购买的虚拟主机空间可以实现1千封邮件的群发么?
- 在DataGrid中File控件改变ImageButton图片 (在线等)
- 神哪,救救我吧!!!!!!!!!!!
- JS验证问题,急!!!!在线等,高手帮帮忙~~~
- 对不住大家了,问个相当简单的问题
DataGrid这个控件如果设置好了,应该挺好使的啊。搂住先仔细看看,有什么问题在详细提。
Width="1000px" Height="411px" AutoGenerateColumns="False" GridLines="Horizontal" CellPadding="3" BackColor="White" BorderWidth="1px" BorderStyle="None"
BorderColor="#E7E7FF" PageSize="12" AllowPaging="True" AllowCustomPaging="True" AllowSorting="True">
<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#738A9C"></SelectedItemStyle>
<EditItemStyle BackColor="Blue"></EditItemStyle>
<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#4A3C8C"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="选择">
<ItemTemplate>
<asp:CheckBox id="cBox" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" HeaderText="编辑" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:BoundColumn DataField="id" SortExpression="id" HeaderText="ID">
<HeaderStyle Width="40px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="姓名" SortExpression="姓名" HeaderText="姓名"></asp:BoundColumn>
<asp:BoundColumn DataField="性别" SortExpression="性别" HeaderText="性别"></asp:BoundColumn>
<asp:BoundColumn DataField="工作时间" SortExpression="工作时间" HeaderText="工作时间" DataFormatString="{0:yyyy年MM月dd日}"></asp:BoundColumn>
<asp:BoundColumn DataField="身份证号" SortExpression="身份证号" HeaderText="身份证号"></asp:BoundColumn>
<asp:BoundColumn DataField="学历" HeaderText="学历"></asp:BoundColumn>
<asp:BoundColumn DataField="职称" HeaderText="职称"></asp:BoundColumn>
<asp:BoundColumn DataField="岗位" HeaderText="岗位"></asp:BoundColumn>
</Columns>
<PagerStyle NextPageText="" PrevPageText="" HorizontalAlign="Right" ForeColor="#4A3C8C" BackColor="#E7E7FF"
PageButtonCount="12" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
recordCount 128 int
DataGrid1.PageCount.ToString() = 1