I am building a datatable ("Key", "value") out of a collection object ("Key","value","rank","child") and then binding to the checkboxlist. (This works fine)
Now, I need to bind the data to checkbox list in such a way that for a collection object -
- Indenting any values that have a "rank" of 2
- Italicizing any values that have >0 "child" and removing their checkboxes.
Something like - CollectionObjects-
key - value - rank - chil开发者_运维知识库d
1 - discussion - 1 - 0
2 - items - 1 - 2
3 - item provided - 2 - 0
4 - item ordered - 2 - 0
Display as (Ignore text Activity Action)-
I can re-write the entire code the manually add ListItems and add attributes like -
CheckBoxList1.Items[0].Text = "< b >Items< / b >";
CheckBoxList1.Items1.Attributes.Add("style", "margin-left:10px;");
However, this doesn't seem ideal. Can it be done when I have the Datasource as Datatable?
You should define CSS classes for each level of your list items, then as you create them, attach the correct style tags to each element. That way you can fine tune formatting without having hard code style information in your application.
Have a look at enter link description here for some basic getting started info.
When creating the list items you add a style attribute like
ListItem li = new ListItem("my list item");
li.Attributes.Add("style", "font-style:italic;");
This will render the item with an italic font.
精彩评论