Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8339063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:46:48+00:00 2026-06-09T04:46:48+00:00

I have a standard dropdown list and am able to databind to the list.

  • 0

I have a standard dropdown list and am able to databind to the list.

<asp:DropDownList runat="server" ID="ddlMake" ClientIDMode="Static" DataTextField="Name" DataValueField="URL" AppendDataBoundItems="true">
    <asp:ListItem>Select Make</asp:ListItem>
</asp:DropDownList>

I would like to add a data-attribute to the option like below:

<asp:ListItem data-siteid="<%# DataBinder.Eval(Container.DataItem, "SiteID") %>">Select Make</asp:ListItem>

I’m obviously getting an error because it doesn’t recognize the data-siteid.

The list is databound.

Any tips would be handy

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:46:49+00:00Added an answer on June 9, 2026 at 4:46 am

    You could do this in the code-behind. I’m not sure if this is the most elegant approach, but it should work.

    Dim dataSrc() As String = {"ABC", "123", "!@*#"}
    drp.DataSource = dataSrc
    drp.DataBind()
    For i = 0 To drp.Items.Count - 1
        drp.Items(i).Attributes.Add("data-siteId", dataSrc(i))
    Next
    

    Also, if this is just something which is not databound, you could consider using the HtmlSelect control which should work as well:

    <select id="drp2" runat="server">
      <option data-siteId="2">ABC</option>
      <option data-siteId="3">123</option>
      <option data-siteId="4">@*!&</option>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I have a standard dropdown list and when the value in that dropdownlist
I have an asp net application where I use dropdown list. It is not
I have a pretty standard CSS based dropdown menu. The main list is #mainNav
I have an asp:DropDownList on a page that, due to the 1024x768 development standard
I have a standard list view setup with backbone that looks something like below.
I am looking for a POEAA I have a standard ASP.NET MVC View with
I have the following dropdown list: <select id=dropdown> <option value=AB>Alberta Standards</option> <option value=BC>British Columbia
I have a asp.net 2.0 web site with numerous asp:DropDownList controls. The DropDownList control
I have a dropdown list, what I would like to do is assign values
I have a requirement to add a standard drop-down from which you can select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.