asp.net GridView Paging Save options _ Practical Tips

Source: Internet
Author: User

Copy Code code as follows:

#region//' revision:1.00 Created date:2013/08/02 Created Id:una [#1300071] Add multiple Marquee
<summary>
The session takes multiple marquee values
</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>
Multiple marquee is true before session page
</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


Copy Code code as follows:

protected void Gridview_pageindexchanging (object sender, Gridviewpageeventargs e)
{
Rememberoldvalues ();
Gridview.pageindex = E.newpageindex;
Binddata ();
Repopulatevalues ();
}

Copy Code code as follows:

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");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.