0

I just wanted to confirm couple of things.

I) Code snippet:

cmb1.Datasource= dt;
cmb1.Valuemember = "value";

Does the control rendering happens 2 time for the control, 1 more time extra because of the value member getting changed after data source assigned. Is this so?

II) How can I trace these re-populations in C#? I just wanted to debug and see and confirm? Example please?

Thanks Karthik

skaffman
  • 398,947
  • 96
  • 818
  • 769
karthik
  • 449
  • 1
  • 8
  • 22
  • See this question for an answer to question number 2: http://stackoverflow.com/questions/1186080/how-can-i-step-into-microsofts-net-framework-source-code – Hans Olsson Jun 02 '10 at 13:49

2 Answers2

0

This depends on the actual implementation of the data bound control. I'd expect a "good" control to only retrieve the data when it needs it, and therefore changing these properties would not do anything but clear out existing bindings (if there were any) and create the new ones without actually retrieving data.

You can use a profiler to trace such things, or bind to a class of yours and set a breakpoint or increase a counter.

Lucero
  • 59,176
  • 9
  • 122
  • 152
0

I) It depends. If this is for an asp.net site, you have to also call the DataBind() method before anything actually happens. But otherwise, yes - databinding will likely happen twice.

II) You can trace it by building a method that returns a datatable, and binding to that method as the data source. Then you can set a breakpoint inside the method and watch for when the breakpoint is hit.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794