Performance on DropDownList

Nate Bross

Well-known member
Joined
Apr 6, 2005
Messages
601
Location
Chicago, IL
Is there a large performance hit to databind a drop down list to an object with lots of unused properties?

For example:
C#:
class myClass
{
propValue
propData
prop1
prop2
prop3
prop4
prop5
prop6
}

...

ddlList.Datasource = new myClass(....);
ddlList.DataTextField = "propData";
ddlList.DataValueField = "propValue";
ddlList.DataBind();

However, lets imagine that in my example, there are many more extra properties than just six unused in this list.
 
The only real performance hit would be in creating the objects and populating all the properties in the first place. If you are only binding to two properties then only those two will be accessed during the actual binding.

Obviously the overall size will impact memory usage but that is a general performance issue anyway.
 
OK, thanks. Thats what I thought, but I dont really know how the DataSource/DataBind() properties/methods work so I wanted to be sure.

I will already have the object created for use in other areas of the application. I was wondering if I should create a "subset" of these properties in a new object.

Since the performance hit will be creating the objects in the first place, and I already need to do that, binding it to a dropdown list will be more efficent since I wont be creating a second collection of objects.

Thanks for the response.
 
Back
Top