ListItems text not showing in Listbox
<p>The strangest thing happened to me in my asp.net application with a Listbox -- the ListItems are not showing their text. I know they are there because I can see them when I set breakpoints, and on top of that I am using almost the exact same code as I am on another page where they show up just fine. My listbox is on a panel that is called by a modal pop-up that looks like this:</p>

<pre><code>&lt;asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
DynamicServicePath="" Enabled="True" TargetControlID="Button5"
BackgroundCssClass="modalBackground" 
DropShadow="True"
PopupControlID="Panel2" CancelControlID="Button5" OkControlID="Button5"&gt;
&lt;/asp:ModalPopupExtender&gt;
&lt;asp:Panel ID = "Panel2" runat="server" CssClass="modalPopup"&gt;
  &lt;table&gt;
    &lt;tr&gt;
      &lt;td class="style3"&gt;
        &lt;asp:Label ID="Label5" runat="server" Text="The following users are queued front of you. Select 'OK' to add your name  to the queue and 'Cancel' to cancel."&gt;&lt;/asp:Label&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;asp:ListBox ID="ListBox6" runat="server" Width="100%"&gt;&lt;/asp:ListBox&gt;
  &lt;center&gt;
    &lt;asp:Button ID="reqOk" runat="server" Text="OK" onclick="reqOk_Clk" /&gt;
    &lt;asp:Button ID="reqCncl" runat="server" Text="Cancel" onclick="reqCncl_Clk" /&gt;
  &lt;/center&gt;
&lt;/asp:Panel&gt;
</code></pre>

<p>The listbox (ListBox6) is populated like in the code behind page like this:</p>

<pre><code>SqlConnection sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings  
["something"].ConnectionString);
SqlCommand sqlcommand = new SqlCommand();
sqlcommand.Connection = sqlconn;
string cmd = "";
cmd = " SELECT devices.requestQueue, devices.invnumber FROM devices WHERE devices.invnumber='" + str + "'";
sqlcommand.CommandText = cmd;
SqlDataAdapter da = new SqlDataAdapter(sqlcommand);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dt = ds.Tables[0];
object[] obj = dt.Rows[0].ItemArray;
sqlconn.Close();
hasRequest = true;
int i2 = 0;
if (!obj[0].Equals(System.DBNull.Value))
{
  string see = (string)obj[0];
  string[] words = see.Split(',');
  foreach (string word in words)
  {
    i2++;
    if (word.Contains(getname(HttpContext.Current.User.Identity.Name)))
    {
      showStuff = false;
      ListItem item = new ListItem(word);
      ListBox6.Items.Add(item);
      ModalPopupExtender1.Show();
      Label5.Text = "You have already requested " + (string)ViewState["inventory"] + ". Please press cancel and request a different device.";
      reqOk.Visible = false;
    }
    else
    {
      ListItem item = new ListItem(word);
      ListBox6.Items.Add(item);
    }
  }
}
/*foreach (object o in ListBox6.Items)
{
  Label4.Text += o.ToString() + " ";
}*/
if (showStuff == true)
{
  ListBox6.DataBind();
  if (obj[0].Equals(System.DBNull.Value) || (string)obj[0] == "")
    i2 = 0;
  Label5.Text = "The following " + i2 + " user(s) are queued in front of you for device " + str + ". Select 'OK' to add your name to the queue and 'Cancel' to cancel. Your name will not be added to the queue if you select 'Cancel'.";
ModalPopupExtender1.Show();
</code></pre>

<p>What makes this super frustrating is that when I uncomment this peice of code from above:</p>

<pre><code>/*foreach (object o in ListBox6.Items)
{
  Label4.Text += o.ToString() + " ";
}*/
</code></pre>

<p>then Label 4 properly shows each of the items in the ListBox that I want my ListBox to be showing! So, I know the ListItems are being added to the ListBox correctly; I just cannot understand why they are not showing any text in the listbox. Any ideas?? Thanks</p>
