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

  • SEARCH
  • Home
  • 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 6589097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:07:45+00:00 2026-05-25T17:07:45+00:00

I have a data-bound CheckBoxList control that can grow quite large, so I’m trying

  • 0

I have a data-bound CheckBoxList control that can grow quite large, so I’m trying to create a filter for it. Here’s what I’m doing:

foreach( ListItem item in this.UserRolesList.Items ) {
    if( !item.Value.StartsWith( this.RolesFilterList.SelectedValue ) ) {
        item.Attributes.CssStyle["display"] = "none";
    } else item.Attributes.CssStyle["display"] = "inline";
}

This mostly works, except that when ASP.NET renders the CheckBoxList, it does so using a table, with each CheckBox control nested within its own <TR> element. This means that even though the items I don’t want to see aren’t displayed, the white space for their rows is, so there’s quite a bit of whites pace I still need to content with.

I’m not aware that I can access the <TR> element without subclassing the control, which this being a “nice-to-have” feature I don’t have time to do, so I’m wondering if there’s a CSS trick I can use to access an element’s parent’s parent (e.g., <input type="checkbox"/> -> <td> -> <tr>). I’ve used the :first-child pseudo-element before, but my web searches for this kind of trick have been fruitless, so I have my doubts. Can’t hurt to ask though, right?

  • 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-25T17:07:45+00:00Added an answer on May 25, 2026 at 5:07 pm

    This might work for you. It removes the item from the list completely so that it does not get rendered at all:

    string value = this.RolesFilterList.SelectedValue;
    int count = this.UserRolesList.Items.Count - 1;
    
    for(var i=count;i>=0;i--)
    {
        ListItem item = this.UserRolesList.Items[i];
        if (!item.Value.StartsWith(value))
        {
            this.UserRolesList.Items.RemoveAt(i);
        }
    }
    

    Update

    Based on your comment above about how you want this to operate from a user’s standpoint, you would probably be better off doing this all client-side in javascript, rather than doing it on a postback in this manner.

    In jQuery, you could create a function to run when the select list is changed that would then find all the checkboxes in the UserRolesList table, and then loop through them, and based on their value use the .closest('tr') function to hide/show the whole table row that contains them.

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

Sidebar

Related Questions

I have a data-bound, templated control, and inside the templated area I create a
I have a problem with a data-bound DataGrid control, in that despite each column
I have a .NET repeater control that is data-bound to a List. As part
I use ADO.NET Entity-Framework, I have a page that is data-bound to an entity
I have a repeater that's bound to a SQL Data Source (using ASP.NET). Are
Assume that I have the ItemSource bound and i am getting the data. Now
I have a grid view that is data bound to a dataset. In a
I have a UserControl that contains a TextBox. The TextBox.Text property is data-bound and
What is the best way to create a data bound ASP.NET user control? I
I have been trying to use declarative data bound ASP.NET, and struggling with the

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.