By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,570 Members | 970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,570 IT Pros & Developers. It's quick & easy.

Listbox on an AJAX TAB CONTAINER postback problem

P: 1
Good Morning,
I have a problem with my listbox control, and i tried everything i found on the web but maybe i'm still missing something.
I have a listbox that i control with a datatable <the data table is populated through a data layer which is a seperate application> and i bind it to the listbox,
on selecting an item from that listbox, a second dropdownlistbox should be activated.

My problem is that when i do postback to activate the second dropdownlistbox, the first get emptied, i dont know whats the problem.

here is my code.
<source code>
Expand|Select|Wrap|Line Numbers
  1. <asp:DropDownList ID="IndexDropDownList" runat="server" AutoPostBack="True" AppendDataBoundItems="True"
  2.                                             Height="18px" Width="301px" 
  3.                                             onselectedindexchanged="IndexDropDownList_SelectedIndexChanged">
on behind page code is
Expand|Select|Wrap|Line Numbers
  1. public partial class markit_Index : System.Web.UI.Page
  2. {
  3.     protected void Page_Load(object sender, EventArgs e)
  4.     {
  5.         if (!IsPostBack)
  6.         {
  7.             DataTable data = new DataTable();
  8.  
  9.             Getdata();
  10.       }
  11.    }
  12.  
  13. protected void  Getdata ()
  14.     {
  15.         DataSet MyDataset = new DataSet();
  16.  
  17.  
  18.         CurveDao iDao = new CurveDao("", ContextManager.oracleSession);
  19.  
  20.         DataTable data = iDao.GetIndexCompositionData();
  21.         Session["GetIndexCompositionData"]= data;
  22.  
  23.         DataTable table = new DataTable();
  24.         table.Columns.Add("Index Name");
  25.         foreach (DataRow row in data.Select())
  26.         {
  27.             DataRow NewRow = table.NewRow();
  28.             String IndexName = row["Name"].ToString();
  29.             NewRow["Name"] = Name;
  30.                  table.Rows.Add(NewRow);
  31.         }
  32.         IndexDropDownList.DataSource =table;
  33.         IndexDropDownList.DataTextField = "Name";
  34.         IndexDropDownList.DataBind();
  35.  
  36.     }
  37.  
  38.  protected void IndexDropDownList_SelectedIndexChanged(object sender, EventArgs e)
  39.     {
  40.  
  41.  
  42.         IndexNameDropDownList.Enabled = true;
  43.  
  44.      }
  45.  
  46. }

Thanks for the help !!
Aug 6 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.