Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I what buid a custom attribute of select box,this attribute has a property is "listItem",how can
to load data value to the property of listitem?
Posted

 
Share this answer
 
v2
Comments
fjdiewornncalwe 16-Jan-13 9:53am    
My 5.
Abhinav S 16-Jan-13 11:39am    
Thank you.
XML
<select>
<option value="1" data-value="myValue1">item</option>
<option value="2" data-value="myValue2">item</option>
<option value="3" data-value="myValue3">item</option>
</select>



<select id="selectList" class="multiselect" multiple="true" name="selectList[]" runat="server">&lt;/select>


ListItemCollection values = new ListItemCollection();
ListItem test = new ListItem("add");
test.Attributes.Add("data-value", "myValue");
values.Add(test);
this.selectList.DataSource = values;
this.selectList.DataBind();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900