I\'m working with asp.net and c# Lets say I have a bunch of drop-downs and I wan
ID: 645909 • Letter: I
Question
I'm working with asp.net and c#
Lets say I have a bunch of drop-downs and I want to bind data from a database, is it better to make a master-bind method that loops each one and gets the parameters to bind them all or make a method for each one of the drop-downs?
Right now the program has the masterbind method that binds all the dropdowns, it does its work, but since I got asked to rebuild that whole form, I wanted to know which one is optimal. I've searched the web... some people say that one method is better others say that individual methods are better.
Explanation / Answer
It depends on the complexity of the binding operation. If it's just one line to populate the dropdown, encapsulating that in a method is unnecessary. If it's a dozen lines of database queries and looping over the result and whatever else, having a populateDropdownA method makes sense.