简体   繁体   English

在下拉列表中显示公司名称和徽标

[英]Display companyname and logo in dropdownlist

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. 我有指定公司名称和图像的xml文件。 Structure of xml file: xml文件的结构:

 <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 使用jQuery http://www.htmldrive.net/items/show/749/Image-Select-Elements-with-jQuery-and-CSS3.html尝试一下

Or try this http://designwithpc.com/Plugins/ddSlick 或尝试使用此 http://designwithpc.com/Plugins/ddSlick

At example 2.. the HTML need to look like this 在示例2中。HTML需要如下所示

 <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 您可以通过绑定到中继器从“代码隐藏”中创建HTML

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM