one objectdatasource for multiple listboxes

Discussion in '.NET' started by bugmenot, Feb 26, 2008.

  1. bugmenot

    bugmenot

    Joined:
    Jul 10, 2006
    Messages:
    7
    I'm trying to get an objectdatasource to bind data to 2(to start) different listboxes. The selectmethod is the same but the parameter values are different and are determined by the listbox being populated.

    I'd prefer that as much coding be in the code behind file(C#).
    Right now i can get the objectdatasource to populate both listboxes, but when one listbox is populated the other gets the same data. I want it to retain the data that it already had. the objectdatasource should only populate one listbox.

    objectdatasource
    Code:
    <asp:ObjectDataSource ID="ObjectDataSource2"  TypeName="dataType"  runat="server" > </asp:ObjectDataSource>
    code behind:
    Code:
    if (!listb.Visible)
             {
                 switch (clicked.ID.ToString())
                {
                    case "btnAdd":
                        ObjectDataSource2.SelectParameters["arg1"].DefaultValue="data1";
                        ObjectDataSource2.SelectParameters["arg2"].DefaultValue = "data2";
                        ObjectDataSource2.SelectParameters["arg3"].DefaultValue = "data3";
                        break;
                    case "btnAddTeam":
                        ObjectDataSource2.SelectParameters["arg1"].DefaultValue = "data1";
                        ObjectDataSource2.SelectParameters["arg2"].DefaultValue ="data2";
                        ObjectDataSource2.SelectParameters["arg3"].DefaultValue = "data3";
                        break;
                }
                 clicked.Text = DONE;
                 listb.Visible = true;
             }
     
    bugmenot, Feb 26, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bill yeager

    listboxes.........

    bill yeager, Aug 8, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    639
    Prakash
    Aug 11, 2003
  2. jason@cyberpine.com
    Replies:
    1
    Views:
    292
    jason@cyberpine.com
    Nov 5, 2003
  3. loveNUNO
    Replies:
    2
    Views:
    933
    loveNUNO
    Nov 20, 2003
  4. Jeffrey Barish
    Replies:
    0
    Views:
    293
    Jeffrey Barish
    Apr 19, 2004
  5. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    248
    Steven Cheng[MSFT]
    Mar 23, 2006
Loading...

Share This Page