public void Populate_ListBoxes(string subj) { var elements = subj.Split(new[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries); string lname = null; foreach (string items in elements) { lname = Get_Subjects(items); ListItem li = new ListItem(); li.Text = lname; li.Value = items; //ListItem la = listA.Items.FindByValue(items); listB.Items.Add(li); //compare lname to each of the listItem's text value //If comparison successful --> Remove that item from list. //I dont know how to compare because listA.Items.Count returns 0 //How can it return 0 if sqlDataSource is populating listA with some listItems ? ? ?? } }
listA.Items.Count
<td> <asp:ListBox ID="listA" runat="server" DataSourceID="SqlDataSourceSubjects" DataTextField="subject" DataValueField="subjectID" Rows="6" SelectionMode="Multiple" AutoPostBack="True"></asp:ListBox> <asp:SqlDataSource ID="SqlDataSourceSubjects" runat="server" ConnectionString="<%$ ConnectionStrings:myconnectionstring %>" SelectCommand="SELECT subjectID, subject FROM mast_subject"> </asp:SqlDataSource> </td> <td> <asp:Button ID="btnlistAtolistB" runat="server" OnClick="btnlistAtolistB_Click" Text=">>" /> <asp:Button ID="btnlistBtolistA" runat="server" OnClick="btnlistBtolistA_Click" Text="<<" /> </td> <td> <asp:ListBox ID="listB" runat="server" Rows="6" SelectionMode="Multiple"> </asp:ListBox> </td>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)