跳转按钮

lemowenzi 2003-10-17 08:22:52
在DataGrid里除了上下页外,我想加个跳转按钮怎么做
...全文
40 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
rengang11 2003-10-17
  • 打赏
  • 举报
回复
public int bindCostList(ref System.Web.UI.WebControls.DataGrid listGrid,String strWhere,int intPage)
{
int rowsCount = 0;
//从视图(othercost)取值
String strSel = "Select proj_id,cost_type_des,cost_id,cost_name,cost_des,provide_name,price,quantity,cost_flag_des,other_cost_id, (price * quantity) as totalprice From othercost ";
strSel = strSel + strWhere;
DataTable datatable = new DataTable();
datatable = dataManager.getDataTable(strSel);
listGrid.DataSource = datatable;
rowsCount = datatable.Rows.Count;
int intFact = rowsCount/listGrid.PageSize;
int intFactRe = rowsCount%listGrid.PageSize;
if(intFactRe != 0)
{
intFact ++ ;
}
if(intPage > intFact)
{
listGrid.CurrentPageIndex = intFact - 1;
listGrid.DataBind();
return rowsCount;
}
else
{
listGrid.DataBind();
return rowsCount;
}
}
rengang11 2003-10-17
  • 打赏
  • 举报
回复
把里面的类稍微该一下就行了
框架就这样了
lemowenzi 2003-10-17
  • 打赏
  • 举报
回复
ok!谢谢!!!
lemowenzi 2003-10-17
  • 打赏
  • 举报
回复
在线给分
高分求救!!!!!!!
rengang11 2003-10-17
  • 打赏
  • 举报
回复
#region 页数跳转按钮
/// <summary>
/// 页数跳转按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnGo_Click(object sender, System.EventArgs e)
{
//String strErrMsg = "对不起,您输入页码不正确";
String temp = "";
System.Text.StringBuilder messBuilder = new System.Text.StringBuilder();
if(txtBoxPage.Text == "")
{
//空值处理
this.Page.RegisterStartupScript("",@"<script>alert('"+promng.common.MessageLog.getMessage("M0002","跳转页面")+"')</script>");
return;
}
else
{
//正整数校验
messBuilder.Append(otherCostManage.checkProInt(txtBoxPage.Text,"页码"));
}
temp = messBuilder.ToString();
if(temp != "")
{
this.Page.RegisterStartupScript("",@"<script>alert('"+temp+"')</script>");
this.txtBoxPage.Text = "";
return;
}
//转换类型
int intPage = int.Parse(txtBoxPage.Text);
//输入值范围判断
if(intPage > gridCost.PageCount)
{
//String strMess = promng.common.MessageLog.getMessage("M0033");
this.Page.RegisterStartupScript("",@"<script>alert('"+promng.common.MessageLog.getMessage("M0033")+"')</script>");
this.txtBoxPage.Text = "";
return;
}
//取得项目编号,重新绑定数据列表
String strWhere =" where proj_id = '"+(String)ViewState["proj_id"]+"'";
int intSecondPage = intPage -1;
gridCost.CurrentPageIndex = intSecondPage;
//返回实际总行
int intResult = this.otherCostManage.bindCostList(ref gridCost,strWhere,intPage);
//总行除于页面尺寸
int intPageRe = intResult%gridCost.PageSize;
if( intPageRe != 0)
{
intPageRe = 1;
}
int intPageCount = (intResult/gridCost.PageSize) + intPageRe;
pagetext(intResult.ToString(),intPageCount - 1,intPageCount);
//清空输入框
txtBoxPage.Text = "";
}
#endregion

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧