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

