asp.net Gridview分頁(yè)保存選項(xiàng)
#region //'Revision: 1.00 Created Date: 2013/08/02 Created ID: Una [#1300071]增加多選框
/// <summary>
/// Session獲取多選框值
/// </summary>
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;
}
/// <summary>
/// Session分頁(yè)時(shí)之前多選框?yàn)閠rue
/// </summary>
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分頁(yè)的實(shí)現(xiàn)以及自定義分頁(yè)樣式功能實(shí)例
- GridView自定義分頁(yè)的四種存儲(chǔ)過(guò)程
- C#自定義DataGridViewColumn顯示TreeView
- yii2.0之GridView自定義按鈕和鏈接用法
- GridView自定義刪除操作的具體方法
- 自定義GridView并且實(shí)現(xiàn)拖拽(附源碼)
- asp.net gridview自定義value值的代碼
- asp.net gridview分頁(yè):第一頁(yè) 下一頁(yè) 1 2 3 4 上一頁(yè) 最末頁(yè)
- asp.net中的GridView分頁(yè)問(wèn)題
- Android入門之ActivityGroup+GridView實(shí)現(xiàn)Tab分頁(yè)標(biāo)簽的方法
- 基于GridView和ActivityGroup實(shí)現(xiàn)的TAB分頁(yè)(附源碼)
- GridView自定義分頁(yè)實(shí)例詳解(附demo源碼下載)
相關(guān)文章
asp.net Request.ServerVariables[] 讀解
asp.net Request.ServerVariables[] 讀解,學(xué)習(xí).net的朋友可以參考下,方便獲取服務(wù)器的一些信息。2011-08-08
asp.net DropDownList實(shí)現(xiàn)二級(jí)聯(lián)動(dòng)效果
這篇文章主要介紹了asp.net DroDownList實(shí)現(xiàn)二級(jí)聯(lián)動(dòng)效果的相關(guān)資料,需要的朋友可以參考下2016-02-02
.Net整合Json實(shí)現(xiàn)REST服務(wù)客戶端的方法詳解
這篇文章主要給大家介紹了關(guān)于.Net整合Json實(shí)現(xiàn)REST服務(wù)客戶端的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2018-01-01
asp.net實(shí)現(xiàn)C#繪制太極圖的方法
這篇文章主要介紹了asp.net實(shí)現(xiàn)C#繪制太極圖的方法,實(shí)例分析了asp.net繪制圖形的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-02-02
.NetCore使用Swagger+API多版本控制的流程分析
這篇文章主要介紹了.NetCore使用Swagger+API多版本控制的流程分析,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-12-12
獲取創(chuàng)建Membership的數(shù)據(jù)庫(kù)創(chuàng)建腳本
membership的數(shù)據(jù)庫(kù)可以通過(guò)aspnet_regsql.exe來(lái)配置生成,但是里面的東西,不一定都是我需要的,有時(shí)我也想自定義一些東西。2010-02-02

