Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC
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 15-Jan-13 17:45pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Comments
Marcus Kramer at 16-Jan-13 9:53am
   
My 5.
Abhinav S at 16-Jan-13 11:39am
   
Thank you.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

<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();
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100