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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:11:05+00:00 2026-05-30T14:11:05+00:00

I added some custom attributes to checkboxlist, but I wonder why I failed to

  • 0

I added some custom attributes to checkboxlist, but I wonder why I failed to retrieve the values of custom attributes. It will be something like this post jQuery – find control using custom attribute. But what I want is retrieve through auto postback and code behind.

int temp = 0;
foreach (DataRow rows1 in ds_ss_equipments_data.Tables[0].Rows)
{
    cblEquip.Items.Add(new ListItem(rows1["name"].ToString() + " " + rows1["quota"].ToString() + " X " + rows1["price"].ToString(), rows1["id"].ToString()));
    cblEquip.Items[temp].Attributes["price"] = rows1["price"].ToString();
    cblEquip.Items[temp].Attributes["id"] = rows1["id"].ToString();
    cblEquip.Items[temp].Attributes["quota"] = rows1["quota"].ToString();
    temp += 1;
}



foreach (ListItem li in cblEquip.Items)
{
    if (li.Selected)
    {
        equip += (Convert.ToDecimal(li.Attributes["price"]) * Convert.ToInt32(li.Attributes["quota"]));     
    }
}
  • 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-30T14:11:06+00:00Added an answer on May 30, 2026 at 2:11 pm

    The link provided by Tim will probably solve your problem. Just a note on your programming style. This temp variable looks very strange. Try this

    foreach (DataRow rows1 in ds_ss_equipments_data.Tables[0].Rows) 
    {                              
        var listItem = new ListItem(rows1["name"].ToString() + " " + ...)
        listItem.Attributes["price"] = rows1["price"].ToString(); 
        listItem.Attributes["id"] = rows1["id"].ToString(); 
        listItem.Attributes["quota"] = rows1["quota"].ToString(); 
        cblEquip.Items.Add(listItem); 
    } 
    

    It is easier an more comprehensible.

    And replace this

    rows1["name"].ToString() + " " + rows1["quota"].ToString() + " X " + rows1["price"].ToString()
    

    By this

    String.Format("{0} {1} X {2}", rows1["name"], rows1["quota"], rows1["price"])
    

    Creating an item will look much prettier like this

    string caption = String.Format(
        "{0} {1} X {2}", 
        rows1["name"], 
        rows1["quota"],
        rows1["price"]
    );
    var listItem = new ListItem(caption, rows1["id"].ToString())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added some animation using jquery but it's not working: $('.test-container').click(function(){ $(this).css('background-color', 'rgb(119,
I was trying to make a custom application form. I've added some control like
I added some custom products in virtuemart from my custom component and added its
In Silverlight 3.0 I have added a custom behavior to some UIElement in Code
I have created several custom attributes for my products. I have some that need
I want to access a custom attribute that I added to some elements in
I've added some extension methods for strings to make working with some custom enums
Delphi 2010 introduced custom attributes which can be added to type declarations and methods.
I've added some custom toolbar buttons to Visual Studio that call macros--some I've written,
I added some custom jQuery to the footer static block as documented on Magento

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.