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
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!!
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!


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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Interview questions for support of a legacy ASP.NET site 4 58
Signal R -send data to client: only if they are allowed to see it ? 1 51
Web site error 3 41
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 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