c# - DataBind on CompositeControls -


i have composite control has dropdownlist inside.

the problem have next one: when load data on page_load (the first time page loaded) works fine, when there postback , want refresh datasource (i mean, different one), datasource saved viewstate, not databinded dropdownlist.

i found out happening because page lifecycle changes first time rendered second time:

  • 1st time: page_load - createchildcontrols
  • 2nd time: createchildcontrols - page_load - function_called_on_postback

so problem databind in createchildcontrols() datasource setted on function_called_on_postback(), so, dropdownlist doesn't changes.

do know how can fix this? have @ least advice?

thanks lot!

i'm assuming post being caused event on page such selected index changed on our ddl or click event button. if case, should able set data source of ddl in event handler method of event in question.

for work correctly, have load data ddl in page_load method on initial load not on post backs. can checked page.ispostback.

if(!page.ispostback) { /* initial load data binding of ddl */ } 

Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -