Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3354340
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:15:40+00:00 2026-05-18T02:15:40+00:00

I have a listview with paging. Every paging has 10 rows with with a

  • 0

I have a listview with paging. Every paging has 10 rows with with a username, an email and a checkbox.

I need to be able to check a couple of checkboxes, in different “pagings”, press a button and send an email every to ever user that has been checked.

Trouble is I don’t really know how to remember the selected checkboxes between each paging-press.

Are you with me?

Deos anyone have a similar solution or a few tips on how to do this?
I’d prefer to solv this without jQuery, but ordinare javascript or a C# solution works fine.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:15:41+00:00Added an answer on May 18, 2026 at 2:15 am

    Try this
    http://forums.asp.net/t/1619741.aspx?Remember+checkboxes+in+ListView

    you could maintain a List<> of selections (say ID to each record, unique value) and would have to persist that list in the ViewState. update the list on a page change. bind the checkbox checked property through a code-behind function that checks whether the id is in the list.

    here’s a sample:

            <asp:ListView ID="ListView1" runat="server" OnPagePropertiesChanging="ListView1_PagePropertiesChanging">
                <LayoutTemplate>
                    <table id="Table2" runat="server" class="listview" width="100%">
                        <tr>
                            <td>
                                <table id="itemPlaceholderContainer" runat="server">
                                    <tr>
                                        <th>
                                        </th>
                                        <th>
                                        </th>
                                        <th id="thid" runat="server" visible="false">
                                            ID
                                        </th>
                                        <th id="thname" runat="server">
                                            Name
                                        </th>
                                    </tr>
                                    <tr id="itemPlaceholder" runat="server">
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr id="Tr3" runat="server">
                            <td id="Td2" runat="server" style="">
                                <asp:DataPager ID="DataPager1" runat="server" PageSize="5" PagedControlID="ListView1"
                                    OnPreRender="DataPager1_PreRender">
                                    <Fields>
                                        <asp:NumericPagerField />
                                    </Fields>
                                </asp:DataPager>
                            </td>
                        </tr>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <input type="checkbox" id="CheckBox1" runat="server" value='<%# Eval("ID") %>' checked='<%# Selected(Eval("ID")) %>' />
                        </td>
                        <td>
                            <asp:Label ID="lblID" runat="server" Text='<%# Eval("ID") %>' />
                        </td>
                        <td>
                            <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' />
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:ListView>
    
    code-behind:
    
            List<string> cBoxSelections = new List<string>();
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    BindListView();
                }
            }
    
            private void BindListView()
            {
                ListView1.DataSource = CreateDataSource();
                ListView1.DataBind();
            }
    
            protected DataTable CreateDataSource()
            {
                DataTable dt = new DataTable();
                DataRow dr;
                dt.Columns.Add(new DataColumn("ID", typeof(Int32)));
                dt.Columns.Add(new DataColumn("Name", typeof(string)));
                for (int i = 0; i < 33; i++)
                {
                    dr = dt.NewRow();
    
                    dr[0] = i;
                    dr[1] = string.Concat("Name",i.ToString());
                    dt.Rows.Add(dr);
                }
                return dt;
            }
    
            protected Boolean Selected(object sender)
            {
                Boolean flag = false;
                string ID = Convert.ToString(sender);
                if (!string.IsNullOrEmpty(ID))
                {
                    flag = cBoxSelections.Exists(item => item.Equals(ID));
                }
                return flag;
            }
    
            private void UpdateSelections()
            {
                if (ViewState["sel"] != null)
                {
                    cBoxSelections = (List<string>)ViewState["sel"];
                }
                foreach (ListViewDataItem item in ListView1.Items)
                {
                    HtmlInputCheckBox cbox = (HtmlInputCheckBox)item.FindControl("CheckBox1");
                    if (cbox != null)
                    {
                        string selectedItem = cBoxSelections.Find(key => key.Equals(cbox.Value));
                        if (selectedItem == null)
                        {
                            if (cbox.Checked.Equals(true))
                            {
                                cBoxSelections.Add(cbox.Value);
                            }
                        }
                        if (selectedItem != null)
                        {
                            if (cbox.Checked.Equals(false))
                            {
                                cBoxSelections.Remove(cbox.Value);
                            }
                        }
                    }
                }
                if (cBoxSelections.Count > 0)
                {
                    ViewState["sel"] = cBoxSelections;
                }
            }
            protected void DataPager1_PreRender(object sender, EventArgs e)
            {
                BindListView();
            }
    
    
        protected void ListView1_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
        {
            UpdateSelections();
        }
    

    you need the routines Selected (that returns a boolean) and UpdateSelections (which maintains), the rest of the code simply gets the ListView to demonstrate the sample along with dummy data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView which sometimes I need to put around 10000 items in.
I have a ListView containing file names. These file names need to be draggable
I have a listview with a DataTemplate that has a ComboBox. I want the
I have got ListView with a custom Adapter. Every row contains clickable buttons and
I have a ListView with different layouts for different items. Some items are separators.
I have a ListView with a CheckBox as one of the columns, bound to
I have a ListView that contains a large collection of rows with textboxes that
I have a ListView control, and I'm trying to figure out the easiest/best way
I have a ListView in WPF that is databound to a basic table that
I have a ListView on a page that displays a list of widgets. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.