Important facts about commercial licenses

  • Licenses are perpetual. They do not expire and do not need to be renewed.
  • Licenses can be upgraded. You can upgrade to a more expensive license later paying only the difference in cost.
  • Pay attention to the distribution type - Hosted (sites / servers), binary (applications) or source (includes all the others). Choose according to your needs (more below).
  • All licenses allow commercial use unless otherwise indicated.
  • Read the full license by clicking on the icon.
  • Read more about licenses in our handy license guide.
$14

Personal License

1 site, unlimited servers No source distribution
You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

(1 ratings)

Custom DropDownList

Custom DropDownList
Developed by Blagovest Petrov, Released Apr 11, 2011

A customizable DropDownList control

C#

Tags: asp.net , box , c# , combo

The default DropDownList control for ASP.NET is not very flexible - sometimes we need to fit a dropdown control in tight space or consider other layout restrictions that don't mix well with the default dropdown control.

This DropDownList control is similar to the default but without the arrow (to make it slimmer) and comes with easily customizable CSS.

You can change properties such as:

  • Width
  • Height
  • Row height
  • CSS styles through the includes CSS file
  • Maximum rows shown

And more.

Included in the package is a test page where the functionality of the custom DropDownList is demonstrated.

View all 1 reviews »

User Reviews

  • Ray Howell 2 years ago
    Written in C# this variation to the standard droplist could be really useful, but it needs a few tweaks. The source code is supplied so if required it can be converted to VB if desired although there is no need really. But is you are one of those clever people you could experiment more with the tool., so it is aplus that the source is included as wel las the compiled dll. Remember to set the page AutoEventWireup="true" otherwise you will struggle. This cannot be update via a standard datasource and a way to collect the users choice escapes me at present. I used a sqldatareader to grab data fromn adatabase and using the with statement and a list.add statement as included in the demo code, I could populate the list from a database. Presentation wise it is ok with the sizing working good - in the demo the control has the width set, but take that off and set the css ctr_panel to width:auto and it will size to fit the data which is good - or it cna be contrained at will, same with the height. Also the Rowheight is a good feature and a bit of left padding appled to the ctr_panel etc and the data moves in nicely. I woudl have liked to apply alternate background but it renders to a simple div without spans ot <p> so cant work out if alternate will be possible. Maybe via the Asp mod function? In principle, and certainly for the cost, this is a good tool, but we just have to solve the how to grab the users selection. Regards
    Flag
    Was this helpful? Yes No
Read all 5 comments »

Questions & Comments


Or enter your name and Email
  • Ray Howell License holderPersonal License 2 years ago
    I did convert this to Net.VB but can't get the convert to dll via command line in vs2010 to create a dll otherwise I would have let you have the vb version. My main question with this remains: how programmatically can I get the users selection? Datasource wise I grab values from a database and using the sql reader and the 'with' statement travel through the data then using your item.add statement, each row is add, so that is ok. It is getting the users value which is the problem. Can it be done? Thanks
    • Blagovest Petrov Developer 2 years ago
      In the test page you can see:

      List list = new
      List();
      list.Add(new CustomerDropdownList.ValueName("0","-"));
      for(int i=0;i<=31;i++)
      {
      list.Add(new CustomDropDownList(i.ToString(), i.ToString()));
      }

      CustomDropDownList1.KeyValues = list;

      In this way you create a list which can be use the source for the customdropdown list. You add items to a list and those items contain key and value for the dropdown. Then you bind it to the CustomDropDownList added in your page.
    • Ray Howell License holderPersonal License 2 years ago
      Hi, Thanks what you have is explained is sort of what I am doing except I am pulling data in from a database - see below for the code (I've omitted the connection string) My difficulty is I am not 'seeing' how to grab the value the user selects. Somehow I need get the value or text which populates the 'textbox' I cant seem to add any useful code function in asp.net code page, neither can I add a client onclick, that is what I need help with thanks. I can of course use document.getElementById("") etc, but I would like something where I don't have to 'pre know' the id? and I would like to grab the value via Asp.code nut without runat that isn't going to be easily possible. I could possibly run a javasc function to grab the value from the standard textbox and to place it into a hidden asp.control? Here for clarity is my datasource code:

      Dim list As New List(Of CustomDropDownList.ValueName)

      Dim sql = "SELECT id, model as NList, pos FROM model ORDER BY pos, Model"

      Dim conn As New SqlConnection(connstring)
      Dim objDR As SqlDataReader
      Using Cmd As New SqlCommand(sql, conn)
      conn.Open()
      objDR = Cmd.ExecuteReader()
      While objDR.Read()
      list.Add(New CustomDropDownList.ValueName(objDR("id"), objDR("NList")))
      End While
      End Using

      CustomDropDownList1.KeyValues = list
    • Blagovest Petrov Developer 2 years ago
      HI,

      Then you can just do
      CustomDropDownList1.SelectedValue or
      CustomDropDownList1.SelectedText.
      Depends on what you need.
    • Ray Howell License holderPersonal License 2 years ago
      Hi thanks - was just on the point of saying this dunderhead had realised that when you sent this reply. Thanks. Also, if anyone is interested and haven't worked it out for them selves a stripy background can be applied thus: Set the panel background colour - I used white - then add these 2 CSS statements:
      .ctrl_Panel div:last-child { border-bottom: 1px solid #DDD; }
      .ctrl_Panel div:nth-child(even) { background: #D7E8F0; color:black; }

      Use with an update panel. There seemed to be a problem with use via an Asp update panel. It looked as if the javascript code used within the control doesn't reattach after a partial page reload so the drop part didn't 'open'. Without a panel then it functions fine. In my experiment I was using a textbox to apply a filter to the original sql used to populate the control, but with the update panel this ceased to function, and like I said the control failed to dropdown. Adding an AscPostBack triggers etc didn't solve it - BUT the postback trigger did so we are up an cooking on gas. I still think this is actually a good control. Regards
You must be logged-in to vote. Log-in to your account or register now.