I want to display company name and logo in dropdownlist.I have fetch all the company name in dropdownlist but i am not able to add logo with name.
I have xml file where company name and images are specified. Structure of xml file:
<ente>
<nazione>ALBANIA</nazione>
<name>Tirana</name>
<img>tvsh-albania.png</img>
<descri>TVSH - Rruga Ismail Quemali 11, Tirana</descri>
<latitudine>41.321102</latitudine>
<longitudine>19.823112</longitudine>
<zoom>-4</zoom>
</ente>
I have all images in image folder also.
I have use this code:
Protected Sub BindDataToGridviewDropdownlist()
Dim xmlreader As New XmlTextReader(Server.MapPath("XMLFILE.xml"))
Dim ds As New DataSet()
ds.ReadXml(xmlreader)
xmlreader.Close()
If ds.Tables.Count <> 0 Then
ddlDetails.DataSource = ds
ddlDetails.DataTextField = "nome"
ddlDetails.DataValueField = "nome"
ddlDetails.DataBind()
End If
End Sub
What i need to do so i can also display image with company name.
Dropdown list out of the box does not support adding images. Look for 3rd party components.
我认为很难在html和.net中实现,但是使用jQuery插件应该更容易,例如, 这个
Try this using jQuery http://www.htmldrive.net/items/show/749/Image-Select-Elements-with-jQuery-and-CSS3.html
Or try this http://designwithpc.com/Plugins/ddSlick
At example 2.. the HTML need to look like this
<select id="demo-htmlselect">
<option value="0" data-imagesrc="http://dl.dropbox.com/u/40036711/Images/facebook-icon-32.png"
data-description="Description with Facebook">Facebook</option>
<option value="1" data-imagesrc="http://dl.dropbox.com/u/40036711/Images/twitter-icon-32.png"
data-description="Description with Twitter">Twitter</option>
<option value="2" selected="selected" data-imagesrc="http://dl.dropbox.com/u/40036711/Images/linkedin-icon-32.png"
data-description="Description with LinkedIn">LinkedIn</option>
<option value="3" data-imagesrc="http://dl.dropbox.com/u/40036711/Images/foursquare-icon-32.png"
data-description="Description with Foursquare">Foursquare</option>
</select>
You can create that HTML from Code Behind by binding to a repeater
<asp:Repeater id="rp" runat="server">
<HeaderTemplate>
<select id="demo-htmlselect">
</HeaderTemplate>
<ItemTemplate>
<option value='<%#Container.DataItem("name")%>' data-imagesrc='<%#Container.DataItem("img")%>'
data-description='<%#Container.DataItem("descri")%>'>
<%#Container.DataItem("name")%>
</option>
</ItemTemplate>
<FooterTemplate>
</select>
</FooterTemplate>
</asp:Repeater>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.