views:

149

answers:

0

I am trying here to set correctly a Datasource of a nested control list.

Basic idea :

I have an asp:repeater item. Inside there is a DropDownList and a BulletedList plus a Button.

I want to add the selected Item in the DropDownList from the selected row in the Repeater to be added into the selected row's BulletedList.

So far I managed to do that with OnItemDataBound and OnClick wich is quite good. The problem is the event OnClick is fired after OnItemDataBdound. To view then the Item I added in the BulletedList's datasource I have to refresh the page.

I tried this :

((BulletedList)src.FindControl("sharedPlanDomains")).Items.Clear();

and then

((BulletedList)src.FindControl("sharedPlanDomains")).Datasource = myobject;
((BulletedList)src.FindControl("sharedPlanDomains")).DataBind();

But it seems that it is not working.

((BulletedList)src.FindControl("sharedPlanDomains")).DomainsAssociated.ForEach(f => list.Items.Add(new ListItem { Text = f.Name }));

Doesn't work either.

Any suggestions available ?

[Edit: Clarifications]

Say I have this structure:

  • Hosting Plan : i-Perso
    Domains : [The dropdownlist] [Button: Associate]
    Associated Domains :

    • google.com
    • google2.com
  • Hosting Plan : i-Mense Domains : [The dropdownlist] [Button: Associate] Associated Domains :

    • google3.com

so let's take example that I click on the 1st dropdownlist and select the domain google4.com, then google4.com is going to be added in the datasource of the bulletedlist of the row i-Perso.

What I want to do here is to associate domains and plans. I would have done it better if it would be only a relationship of 1 - 1 but it's a relationshop of 1 - Multiple.