one objectdatasource for multiple listboxes

Joined
Jul 10, 2006
Messages
7
Reaction score
0
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;
         }
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top