asp.net Gridview分頁保存選項(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à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分頁的實(shí)現(xiàn)以及自定義分頁樣式功能實(shí)例
- GridView自定義分頁的四種存儲過程
- C#自定義DataGridViewColumn顯示TreeView
- yii2.0之GridView自定義按鈕和鏈接用法
- GridView自定義刪除操作的具體方法
- 自定義GridView并且實(shí)現(xiàn)拖拽(附源碼)
- asp.net gridview自定義value值的代碼
- asp.net gridview分頁:第一頁 下一頁 1 2 3 4 上一頁 最末頁
- asp.net中的GridView分頁問題
- Android入門之ActivityGroup+GridView實(shí)現(xiàn)Tab分頁標(biāo)簽的方法
- 基于GridView和ActivityGroup實(shí)現(xiàn)的TAB分頁(附源碼)
- GridView自定義分頁實(shí)例詳解(附demo源碼下載)
相關(guān)文章
深入Lumisoft.NET組件POP3郵件接收與刪除操作的使用詳解
本篇文章對Lumisoft.NET組件POP3郵件接收與刪除操作的使用進(jìn)行了詳細(xì)的介紹。需要的朋友參考下2013-05-05Silverlight融合ajax實(shí)現(xiàn)前后臺數(shù)據(jù)交互
兩年前Silverlight 還未起名,故事發(fā)生在WPF/E 的年代里。07年8月在中軟實(shí)習(xí)時,我承擔(dān)起了在. Net 中嵌入WPF/E 的任務(wù),目的是增強(qiáng)用戶體驗(yàn)。2009-05-05asp.net(c#)程序版本升級更新的實(shí)現(xiàn)代碼
我們做了程序,不免會有版本升級,這就需要程序有自動版本升級的功能。那么看看我是如何實(shí)現(xiàn)程序自動更新的。2010-03-03System.Web中不存在類型或命名空間名稱script 找不到System.Web.Extensions.dll引用
這篇文章主要為大家詳細(xì)介紹了System.Web中不存在類型或命名空間名稱script,找不到System.Web.Extensions.dll引用的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04詳解.NET中string與StringBuilder在字符串拼接功能上的比較
string與StringBuilder的在字符串拼接時執(zhí)行效率上有差異,這篇文章主要介紹了詳解.NET中string與StringBuilder在字符串拼接功能上的比較,感興趣的小伙伴們可以參考一下2018-11-11詳解.Net Core + Angular2 環(huán)境搭建
這篇文章主要介紹了詳解.Net Core + Angular2 環(huán)境搭建,具有一定的參考價值,有興趣的可以了解一下。2016-12-12ASP.NET的適配器設(shè)計模式(Adapter)應(yīng)用詳解
有關(guān)設(shè)計模式的適配器模式(Adapter)確實(shí)不是很好理解理解,接下來將做一個簡單的例子簡要說明下,感興趣的朋友可不要錯過了哈,希望本文可以幫助到你更好的理解適配器設(shè)計模式2013-02-02URLRewriter最簡單入門介紹 URLRewriter相關(guān)資源
配置好后,查看日志看到的狀態(tài)都是200,IIS直接認(rèn)為這個文件是存在的了, 而不是301,或302,這在某些情況下可能會不適用,比如:搜索引擎優(yōu)化時目錄或文件調(diào)整。2008-07-07ASP.NET―001:GridView綁定List、頁面返回值具體實(shí)現(xiàn)
這篇文章主要介紹了ASP.NET―GridView綁定List、頁面返回值具體實(shí)現(xiàn),需要的朋友可以參考下2014-02-02