Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Change datasource in javascript?
posted

I have 2 object data sources in my aspx page. I also have a webdropdown. Can I change the datasource the webdropdown is using in the javascript? The number of columns and column names are exactly the same between the two data sources, so there is no customization between the two sources. The event that would cause the data source change would be a checkbox. Roughly it would be like this:

function Check_Change() {

if(checkbox.checked)

webDropDown.DataSource = A

else

webDropDown.DataSource = B

}

<asp:ObjectDataSource ID="A" ..../>

<asp:ObjectDataSource ID="B" ..../>

<asp:Checkbox ID="checkbox" oncheckedchanged="Check_Change(); return false;" />

<igcombo:WebDropDown ID="webDropDown" ..../>

Naturally, I need help ASAP.

Parents
No Data
Reply
  • 24671
    Suggested Answer
    posted

    Hi,

    No, this is not possible from the client-side. I think it is also not possible for any other control. You can still edit (change text and value), add, and remove items on the client-side, and all of these operations will be syncronized with the server-side's databound collection of items. For examples of how to add items programatically, you can refer to the online WebDropDown samples. Note that add/remove/insert automatically causes an async postback. editing item's text and value doesn't, but keeps the changes in a transaction list, so on the next postback server-side's state gets updated as well. 

    Hope it helps,

    Angel 

Children
No Data