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

Problem with dropdown lists in Form

P: 1
Hi Friends,

I have 2 Forms one is ListMenu.aspx and other one is ModifyMenu.aspx.

Listmenu.aspx is to diaply all the menus of Tree View Control in Data Grid.

like First Column is TabName, Second Column is Menu Name and Thid cloumn is Edit in DatGrid.


when i click on Edit its redirected to ModifyMenu.aspx Form using QueryStirng
(tb001_id is passing as querystring)

In ModiyMenu.aspx there are 3 drop down lists are there for

TabName
Child Level
Menu Parent

Now my problem is how to assign the corresponding values from database into these ddl's when i click on edit in datagrid in ListMenu.aspx Form

My code is like this:

Expand|Select|Wrap|Line Numbers
  1. private void bindDataFields(Int32 tb001_id)
  2.     {
  3.         string errorMsg = "";
  4.         DataTable dt = objForm_MTreeBLL.bindFields(tb001_id, ref errorMsg);
  5.         if (errorMsg == "")
  6.         {
  7.             //ddlTabName.SelectedItem.Text = dt.Rows[0]["ptab"].ToString();
  8.             for (int i = 0; i < ddlTabName.Items.Count; i++)
  9.             {
  10.                 if (ddlTabName.Items[i].Text = dt.Rows[0]["ptab"])
  11.                 {
  12.                     ddlTabName.SelectedIndex = Items.Values;
  13.                 }
  14.                 else 
  15.                 {
  16.                     ddlTabName.SelectedIndex = 0;
  17.                 }
  18.             }
  19.  
  20.             txtMenuName.Text = dt.Rows[0]["menu_name"].ToString();
  21.             txtMenuLink.Text = dt.Rows[0]["menu_link"].ToString();
  22.             //ddlConpgid.SelectedItem.Value = Convert.ToString(dt.Rows[0]["conpg_id"]);
  23.             //ddlChildLvl.SelectedItem.Value = Convert.ToString(dt.Rows[0]["child_lvl"]);
  24.             //ddlMenuPrnt.SelectedItem.Value = Convert.ToString(dt.Rows[0]["menu_prnt"]);
  25.             chkMenuActive.Checked = Convert.ToBoolean(dt.Rows[0]["menu_activ"]);
  26.             txtMenuTooltip.Text = dt.Rows[0]["menu_tip"].ToString();
  27.             txtMenuSummary.Text = dt.Rows[0]["menu_sum"].ToString();
  28.         }
  29.         else
  30.         {
  31.             lblMsg.Text = "Error : " + errorMsg;
  32.         }
  33.     }
  34.  
  35.  
i get data into text boxes. not getting data into ddl's

is this code is correct:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  for (int i = 0; i < ddlTabName.Items.Count; i++)
  3.             {
  4.                 if (ddlTabName.Items[i].Text = dt.Rows[0]["ptab"])
  5.                 {
  6.                     ddlTabName.SelectedIndex = Items.Values;
  7.                 }
  8.                 else 
  9.                 {
  10.                     ddlTabName.SelectedIndex = 0;
  11.                 }
  12.             }
  13.  
  14.  
Can you please let me know how to solve this problem

Thanks in advance.

Regards,
Hari
Aug 22 '07 #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.