Nate Bross Posted June 18, 2008 Posted June 18, 2008 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. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Administrators PlausiblyDamp Posted June 20, 2008 Administrators Posted June 20, 2008 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nate Bross Posted June 20, 2008 Author Posted June 20, 2008 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. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.