Binding DataList Containing Checkboxes to a Dictionary


Binding DataList Containing Checkboxes to a Dictionary



I have a DataList like so:

<asp:DataList ID="dlMyList" runat="server" RepeatColumns="5"          RepeatDirection="Horizontal" CellSpacing="5" >     <ItemTemplate>         <asp:CheckBox ID="cbMyBox" Runat="server" Text='<%# Container.DataItem%>' ToolTip=''></asp:CheckBox>     </ItemTemplate> </asp:DataList> 

I'm binding this to a Dictionary:

Dictionary<string, string> l_CheckboxData = GetCheckboxData(); this.dlMyList.DataSource = l_CheckboxData; this.dlMyList.DataBind(); 

At the moment, both the key and the value from the dictionary are set as the Text for each checkbox. I'd like to have it such that they Dictionary's key is the Text property and the Dictionary's value is the ToolTip. How would I go about this? Thanks.




wsdl.exe results in “SOAP 1.1 binding was not found”

1:



How do I use an asp.net user control in another user control?
You can bind to the properties on the DataItem, which, in this case, is a KeyValuePair, having Key and Value properties..
Changing the name in the header for a resource handler in C#
<asp:CheckBox ID="cbMyBox" Runat="server" Text='<%# Eval("Key")%>' ToolTip='<%#Eval("Value")'></asp:CheckBox> 


Design Question - Control Array


82 out of 100 based on 42 user ratings 742 reviews