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 7502543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:54:22+00:00 2026-05-29T20:54:22+00:00

I had recently moved a DataList control in to a UserControl and referenced it

  • 0

I had recently moved a “DataList” control in to a UserControl and referenced it on my ASPX page. The DataList contains checkboxes with checked properties assigned by the data source initially.

<asp:DataList ID="dlspec" CssClass="specs" runat="server" GridLines="Vertical" OnItemDataBound="dlspec_ItemDataBound">
    <FooterStyle BackColor="#CCCCCC" />
    <AlternatingItemStyle CssClass="alt-grey" />
    <SelectedItemStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
      <ItemTemplate>
          <table>
            <tr>
              <td class="leftcol">
                 <asp:Label ID="lblDimension" runat="server" Text='<%# Eval("Dimension") %>'></asp:Label>:
               </td>
               <td class="ProductDetailData">
                    <asp:Label ID="lblName" runat="server" Text='<%# Eval("Attribute") %>'></asp:Label>
               </td>
               <td class="find-similar">
                 <asp:CheckBox ID="FindSimilarCheckbox" runat="server" Checked='<%# Eval("CheckBox")=="true"? true:false %>' Text='<%# Eval("AttributeID") %>' Visible='<%# Eval("CheckBoxState")=="0"? true:false %>' />
                </td>
              </tr>
            </table>
         </ItemTemplate>
       </asp:DataList>

Now, on a button click event in the “aspx” to which the user control is bound to, i try to get the “checked” properties of the check boxes to go through some logic.
I basically use the below to find the usercontrol and loop through the controls in it.

Control SpecsPanel = FindSimilarPnl.FindControl("Specifications").FindControl("dlspec");
foreach (Control ct in SpecsPanel.Controls)
        GetCheckedAttributes(ct, ref qry);

However the “checked’ property of the checkboxes always comes out to be “false” after i moved the datalist in to the user control. Any ideas why? Am I missing something silly? Greatly appreciate any thoughts ideas. Let me know if I need to add more code for you to understand better.
Thanks

  • 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-29T20:54:23+00:00Added an answer on May 29, 2026 at 8:54 pm

    I found out why this is happening…going to answer my own question.
    So the CheckBox ID in the template is “FindSimilarCheckBox” and it is renamed at data-bind time. so when the postback occurs, the server returns the ID’s for all the checkboxes as “FindSimilarCheckBox” and Checked property for everything is false. I had to re-data bind the usercontrol and this time put in a condition to check if it is a postback operation and if the Check Box’s Unique ID exists in the Request.Form collection in order to set the Checked property on the chkbox. Something like this :

    protected void dlspec_ItemDataBound(object sender, DataListItemEventArgs e)
     {
        var ck = e.Item.FindControl("FindSimilarCheckbox") as CheckBox;
                if (ck != null)
                {
                    ck.ID = ck.Text;
                    ck.Text = "";
                    //EDIT: Karthik - Since we moved the Specifications in to user control, check if this a postback , then check to see the CheckBox state on the form while posting back
                    if(IsPostBack && Request.Form[ck.UniqueID] != null)
                    {
                        ck.Checked = true;
                    }
     }
    

    My issue is solved now. Hope this answer helps you understand what caused my issue. Let me know if i need to give more detail.

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

Sidebar

Related Questions

I've recently moved to Java, but I've had some problems with variable aliasing. I've
I recently had a discussion with a colleague about serialization of byte data over
I recently had a blog at www.andrewalaniz.com and I have moved it into a
I have recently moved from Eclipse 3.4 to 3.5. In 3.4 I had a
I recently had to drop the Django development server and moved to apache because
I had recently (and unfortunately) uninstalled the google chrome browser from my computer -while
Here's a problem I've had recently that just HAS to be a common pain
I recently had a similar thread about this, but now I need to animate
I recently had my free application published in Mac Appstore. I'm trying to find
I recently had cause to look at the documentation for the -XX:MaxPermSize argument to

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.