Custom Drop Down list

Posted on 2004-09-24
Last Modified: 2008-01-09
Hi all,

I have a web page which has a datagrid in it. a couple of the columns in this datagrid have a dropdown list. The number of rows present in the grid is dynamic, and changes at runtime quite frequently, but is usually from 5 to 30 or so rows.
Due to client requirements, the rows need to be editable at all times, ie my client is un-willing to accept that the user has to click a button next to a row to bring it to "edit mode" then modify that line, save it, and repeat the process for each row.
One of the dropdown lists has around a hundred and fifty rows in it. an other has around 30 rows. The contents of the drop down lists will not be needing to change during the lifecycle of the form.
I'd like to reduce the html bulk created by repeating the drop-down list multiple times, as each and every dropdown list on the page will present exactly the same options to the client, I'd like the page to download the data once, then render each drop down list at run-time on the client. I've successfully done exactly this for the same application in asp, but now that we've ported the app to .net, it's not quite so simple. I've started looking at creating a Custom Web Control to deal with it, and whilst I'm certain that I'd be able to get it done, I was wondering if anyone else had already done this? Does anyone know of any custom controls available on the web which can do this?
I've not been able to find one, but that doesn't mean there's not one there.

Thanks in advance for your help.
Question by:DementedManiac
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 17

Expert Comment

ID: 12141997
I think your approach is spot on, here are a few resources to help get you started.

Let me know if you need any more help.


LVL 10

Expert Comment

ID: 12147084
If your client is willing to buy this; infragistics has a whole suite of ASP.NET controls, and their WebGrid will do pretty much what you're looking for:

But here are some thoughts with the regular data grid.  If you define the columns with the ddl's as TemplateColumns and then put a ddl in the ItemTemplate, it will be available without having to click an edit button.  Your user could go through row by row, making whatever changes necessary.  Then you would have an update button to post the changes back to the server.

First, make sure you are binding your datagrid to a datatable in a dataset.  You will need to have a data adapter with a select command defined to get the data and fill the datatable.  They key is calling this Fill() method in Page_Load **outside** of the if (!Page.IsPostBack){ } block.  Your page load would look like this:

private void Page_Load(...args here...)
     // get data.

     // check postback.
     if (!Page.IsPostBack)
          // bind grid.

The reason you want the Fill() method called on both the non-postback (the initial load) and on a postback is because when you click the button to update the data changes made by the user you want to do the following:

1) re-fill the datatable.
2) for each row in the grid, resolve the corresponding datarow in the datatable and set the value of the datacolumns with whatever the user has entered by making a selection in the ddls.
3) call the Update() method of the data adapter, passing it the changed datatable.

The first step is accomplished in Page_Load above by putting the Fill() call outside of the postback condition.  #'s 2 and 3 above are then coded in the button's click event, which fires after Page_Load on a postback.


Expert Comment

ID: 12156309
infragistics - good stuff but see the price!!
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.


Author Comment

ID: 12156500
Thanks for your posts.

Aerosaga: I will check out those sites and let you know how I go.

jnhorst: I'll look at the infragistics controls to see if anything will do what I want. Thank you also for your comments re updating the database from the datasource, indeed what you've suggested is a similar approach to what I've implemented. The page is currently working as I described, with each row editable at all times, the optimisation I need is to reduce the bulk of the page by reducing the amount of HTML that is sent to the client. Most of the bulk is currently in the fact that each drop down list and it's respective items have to be sent to the client even though they are identical except for the selected flag on the apropriate item for each list. I'll look at infragistics to see if they have what I need.


LVL 17

Expert Comment

ID: 12365697
recomend point split btwn jnhorst & myself questioner never returned


Author Comment

ID: 12396680
Hi All,

I apologise for taking so long to get back to you all.

AeroSaga: Thank you for the links, they made for some interesting reading, but unfortunately, did not discuss the custom control building techniques I believe I will need to use to get this working.

jnHorst: From what I saw, the Infragistics controls do not do what I need. Rembember, the outcome I am after is to remove the bulk from the page caused by repeating the ddl's potentially dozens of times without having to cause repeated post-back's each time the user needs to change an entry in a list. I had a look through the options, but did not see anything which will do what I need, If you know of a particular tool they make which does this, I'd certainly apreciate knowing which one.

At this stage, I have purchased "Developing Microsoft ASP.NET server controls and components" and am reading through when I have time so that I can learn how to create the control myself.

Thanks for your suggestions.



Accepted Solution

modulo earned 0 total points
ID: 12434152
PAQed, with points refunded (500)

Community Support Moderator

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question