Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Is there a large performance hit to databind a drop down list to an object with lots of unused properties?

 

For example:

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.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

OK, thanks. Thats what I thought, but I don't 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.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...