我的datagrid是通过属性生成器设置的分页属性的,每页显示5条记录,但是运行的时候,完全没有反映,本来一共是10条记录的,应该分为2页显示,但是,导航的“下一页”完全就只是文本。
我的代码如下:
SqlConnection MyConnection=new SqlConnection("server=MY-TOMATO\\HJHSQLSERVER;database=Materials;uid=hjh;pwd=911144");
string SelectCommand=selectyuju.ToString();
SqlCommand MyCommand=new SqlCommand(SelectCommand,MyConnection);
MyCommand.Connection.Open();
SqlDataReader dr;
dr=MyCommand.ExecuteReader();this.DataGrid1.DataSource=dr;
this.DataGrid1.DataBind();
dr.Close();
MyCommand.Connection.Close();int drcount;
drcount=this.DataGrid1.Items.Count;
if (drcount==0)
{
this.Label_jieguo.Text="没有找到满足条件的记录!";
this.Label_currentpage.Text="";
this.Label_pagecount.Text="";
}
else
{
this.Label_jieguo.Text="共找到找到满足条件的记录: "+drcount.ToString()+" 条";
this.Label_currentpage.Text="当前页是: 第 "+this.DataGrid1.CurrentPageIndex.ToString()+" 页";
this.Label_pagecount.Text="页的总数是: "+this.DataGrid1.PageCount.ToString()+" 页";
} 不仅“上一页”,“下一页”完全是文本,而且结果是:(正确的应该是共找到记录:10条, 当前为:第1页, 页总数是:2页) ,谁能帮我看看啊
共找到找到满足条件的记录: 5 条 当前页是: 第 0 页 页的总数是: 1 页上一页 下一页
材料名
15MnVn(Ti)钢
16Mn钢
16Mn钢圆棒焊接接头
18Cr2Ni4W钢
20钢
上一页 下一页
我的代码如下:
SqlConnection MyConnection=new SqlConnection("server=MY-TOMATO\\HJHSQLSERVER;database=Materials;uid=hjh;pwd=911144");
string SelectCommand=selectyuju.ToString();
SqlCommand MyCommand=new SqlCommand(SelectCommand,MyConnection);
MyCommand.Connection.Open();
SqlDataReader dr;
dr=MyCommand.ExecuteReader();this.DataGrid1.DataSource=dr;
this.DataGrid1.DataBind();
dr.Close();
MyCommand.Connection.Close();int drcount;
drcount=this.DataGrid1.Items.Count;
if (drcount==0)
{
this.Label_jieguo.Text="没有找到满足条件的记录!";
this.Label_currentpage.Text="";
this.Label_pagecount.Text="";
}
else
{
this.Label_jieguo.Text="共找到找到满足条件的记录: "+drcount.ToString()+" 条";
this.Label_currentpage.Text="当前页是: 第 "+this.DataGrid1.CurrentPageIndex.ToString()+" 页";
this.Label_pagecount.Text="页的总数是: "+this.DataGrid1.PageCount.ToString()+" 页";
} 不仅“上一页”,“下一页”完全是文本,而且结果是:(正确的应该是共找到记录:10条, 当前为:第1页, 页总数是:2页) ,谁能帮我看看啊
共找到找到满足条件的记录: 5 条 当前页是: 第 0 页 页的总数是: 1 页上一页 下一页
材料名
15MnVn(Ti)钢
16Mn钢
16Mn钢圆棒焊接接头
18Cr2Ni4W钢
20钢
上一页 下一页
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货