Click here to Skip to main content
15,887,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everybody ,
this is my first post ever on code project so please help me out ,
I am having a parent page create Items in which a user control ucCreateItems is opened which contains a dropdown list of categories ,
on a button click of this user control a new pop up opens called PopUpCreate categories opens
which is an aspx page in which a user control ucCreateCategories is opened where we can create new categories .When a category is created through a pop up,i want that the dropdown list of the first page create item is populated and newly created category is selected automatically, so a little help about how to get the control (dropdown list ) of first usercontrol be get in the pop up user control so that i cam bind it dynamically .

here is the code----->>>>>
C#
protected void Page_Load(object sender, EventArgs e)
     {
         try
         {
            // (DropDownList)DropDownListCategory = (DropDownList)Parent.FindControl("");
             objItem.CompanyId = objcategory.CompanyId = Convert.ToInt64(Session["LoginCompanyId"]);

             if (!Page.IsPostBack)
             {
                 BindItemUnit();

                 //  this.AddNodes(this.TreeviewCategories.Nodes, 0, objcategory.GetCategories());
                 DataTable CategoriesDropDownFill = objcategory.GetCategories();
                 DropDownListCategory.DataSource = CategoriesDropDownFill;
                 DropDownListCategory.DataTextField = "CategoryName";
                 DropDownListCategory.DataValueField = "CategoryId";
                 DropDownListCategory.DataBind();
                 DropDownListCategory.Items.Insert(0, new ListItem("-Select-", 0.ToString()));
                 if (Request.QueryString["ItemId"] != null)
                 {
                     H1Text.InnerHtml = "Edit item";
                     GetItemDetail();

                 }
                 else
                 {
                     H1Text.InnerHtml = "New item";
                 }
                 LabelCurrency.Text = LabelCurrency2.Text = Session["currencyName"].ToString();

             }
         }
         catch (Exception ex)
         {
             objErrorLog.InsErrorLog(ex.Message.ToString(), "~/Master/Items/CreateItem.aspx", "Page_Load()",
                 Convert.ToInt32(Session["LoginUserId"]));
         }
     }
     public void BindItemUnit()
     {
         ItemUnit objitemunit = new ItemUnit();
         objitemunit.CompanyId = Convert.ToInt64(Session["LoginCompanyId"]);
         var listUnit = objitemunit.FillUnits().ToList();
         DropDownListUnit.DataSource = listUnit;
         DropDownListUnit.DataTextField = "Unit";
         DropDownListUnit.DataValueField = "UnitId";
         DropDownListUnit.DataBind();
         DropDownListUnit.Items.Insert(0, new ListItem("-Select-", 0.ToString()));
     }


Here i want to get the control of the create item user control

C#
protected void ButtonSave_Click(object sender, EventArgs e)
   {
       try
       {
           if (Request.QueryString["Id"] != null)
           {
               objCategory.CategoryId = Convert.ToInt32(Request.QueryString["Id"].ToString());

           }
           objCategory.ParentId = Convert.ToInt64(DropDownListParentCategory.SelectedValue);
           objCategory.CategoryName = TextBoxCategoryName.Text;
           objCategory.Description = TextBoxDescription.Text;
           objCategory.CreatedBy = Convert.ToInt32(Session["LoginUserId"]);
           objCategory.LastModifiedBy = Convert.ToInt32(Session["LoginUserId"]);
           objCategory.CompanyId = Convert.ToInt64(Session["LoginCompanyId"]);

           if (objCategory.IsExist() > 0)
           {
               LabelMsg.Text = "Category with same name already Exist.";
           }

           else
               if (objCategory.AddUpdateNewCategory() > 0)
               {
                   if (Request.QueryString["Type"]!=null)
                   {
                       HiddenFieldLastInsertedDropDownValue.Value = objCategory.AddUpdateNewCategory().ToString();
                       string script = "BinducCreateItemDropDown();";
                       ScriptManager.RegisterStartupScript(this, this.GetType(), "BinducCreateItemDropDown", script, true);
                   }
                   else
                   {
                       string script = "Redirect();";
                       ScriptManager.RegisterStartupScript(this, this.GetType(), "Redirect", script, true);
                   }
               }

       }


C#
if (Request.QueryString["Type"]!=null)
                       {
                           HiddenFieldLastInsertedDropDownValue.Value = objCategory.AddUpdateNewCategory().ToString();
                           string script = "BinducCreateItemDropDown();";
                           ScriptManager.RegisterStartupScript(this, this.GetType(), "BinducCreateItemDropDown", script, true);
                       }



its here i want to get the control dropdown list categories
Posted
Updated 8-Aug-13 23:55pm
v2
Comments
BillWoodruff 14-Aug-13 19:42pm    
This situation, what I can understand of it, suggests an over-engineered solution. To be able to help you with this we need a simple overview of the tasks at hand, and their order, and different options the user has at each step through what appears to be a process of configuring and editing. My "gut" tells me what you are trying to do here can be done much more simply.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900