您现在的位置是:网站首页> 编程资料编程资料
asp.net Gridview分页保存选项_实用技巧_
2023-05-24
450人已围观
简介 asp.net Gridview分页保存选项_实用技巧_
#region //'Revision: 1.00 Created Date: 2013/08/02 Created ID: Una [#1300071]增加多選框
///
/// Session獲取多選框值
///
private void RememberOldValues()
{
ArrayList categoryIDList = new ArrayList();
string index = "";
foreach (GridViewRow row in gridView.Rows)
{
index = (string)gridView.DataKeys[row.RowIndex].Value;
bool result = ((CheckBox)row.FindControl("DeleteThis")).Checked;
// Check in the Session
if (Session["id"] != null)
categoryIDList = (ArrayList)Session["id"];
if (result)
{
if (!categoryIDList.Contains(index))
categoryIDList.Add(index);
}
else
categoryIDList.Remove(index);
}
if (categoryIDList != null && categoryIDList.Count > 0)
Session["id"] = categoryIDList;
}
///
/// Session分頁時之前多選框為true
///
private void RePopulateValues()
{
ArrayList categoryIDList = (ArrayList)Session["id"];
if (categoryIDList != null && categoryIDList.Count > 0)
{
foreach (GridViewRow row in gridView.Rows)
{
string index = (string)gridView.DataKeys[row.RowIndex].Value;
if (categoryIDList.Contains(index))
{
CheckBox myCheckBox = (CheckBox)row.FindControl("DeleteThis");
myCheckBox.Checked = true;
}
}
}
}
#endregion
protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
RememberOldValues();
gridView.PageIndex = e.NewPageIndex;
BindData();
RePopulateValues();
}
protected void btnSelect_Click(object sender, EventArgs e)
{
string items = "";
ArrayList categoryIDList = new ArrayList();
string index ="";
foreach (GridViewRow row in gridView.Rows)
{
index = (string)gridView.DataKeys[row.RowIndex].Value;
bool result = ((CheckBox)row.FindControl("DeleteThis")).Checked;
// Check in the Session
if (Session["id"] != null)
categoryIDList = (ArrayList)Session["id"];
if (result)
{
if (!categoryIDList.Contains(index))
categoryIDList.Add(index);
}
else
categoryIDList.Remove(index);
}
if (categoryIDList != null && categoryIDList.Count > 0)
for (int i = 0; i < categoryIDList.Count; i++)
{
items += categoryIDList[i] + ",";
}
items = items.Substring(0, items.Length - 1);
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "check('" + items + "');", true);
Session.Remove("id");
}
- GridView分页的实现以及自定义分页样式功能实例
- GridView自定义分页的四种存储过程
- C#自定义DataGridViewColumn显示TreeView
- yii2.0之GridView自定义按钮和链接用法
- GridView自定义删除操作的具体方法
- 自定义GridView并且实现拖拽(附源码)
- asp.net gridview自定义value值的代码
- asp.net gridview分页:第一页 下一页 1 2 3 4 上一页 最末页
- asp.net中的GridView分页问题
- Android入门之ActivityGroup+GridView实现Tab分页标签的方法
- 基于GridView和ActivityGroup实现的TAB分页(附源码)
- GridView自定义分页实例详解(附demo源码下载)
相关内容
- vs2010根据字符串内容添加断点的方法介绍_实用技巧_
- C# 实现抓取网站页面内容的实例方法_实用技巧_
- 某个aspx页面突然死了连日志也没有的解决方法_实用技巧_
- Asp.net的GridView控件实现单元格可编辑方便用户使用_实用技巧_
- 模拟QQ心情图片上传预览示例_实用技巧_
- Global.asax的Application_Error实现错误记录/错误日志的代码_实用技巧_
- Global.asax的Application_BeginRequest实现url重写无后缀的代码_实用技巧_
- 详细说明asp.net中datareader 和 dataset 的区别_实用技巧_
- asp.net中GridView控件遍历的小例子_实用技巧_
- asp.net 通用的连接数据库实例代码_实用技巧_
