PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Setting Properties-VBForums
Results 1 to 2 of 2

Thread: Setting Properties

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jul 2018
    Posts
    1

    Setting Properties

    Here is the solution with code


    0
    down vote
    favorite
    i have a UC_Categories.ascx ( UC_1 ) which constraints categoryname . UC_Products.ascx ( UC_2 ) will show products by categoryname. Both of them are in a Page called BookShop.aspx ( Page )

    In the Page, when user click a UC_1 (step 1 ) , it will render a UC_2 by categoryname (step2 ). I process step 1 by sending a request with param that is categoryname to Page. Step2 create a new UC_2 ,set Properties value that is categoryname , and execute FillProductByCategoryName method. then add UC_2 to a PlaceHolder in the Page. but i don't show UC_2 .

    I need a help or suggest from everyone.

    Thank you for reading my question! ps : my english isn't very well.

    in the codebehind of the UC2 :
    Code:
    public void FillProduct()
    {

    ProductsMN productsMN = new ProductsMN();
    if (dlBook == null)
    {
    dlBook = new DataList();
    dlBook.DataSource = productsMN.GetByCategoryName(CategoryName);
    dlBook.DataBind();
    }
    else
    {
    dlBook.DataSource = productsMN.GetByCategoryName(CategoryName);
    dlBook.DataBind();
    }
    }

    public string CategoryName { get; set; }
    in the codebehind of the page

    protected void Page_Load(object sender, EventArgs e)
    {

    if (!IsPostBack)
    {
    }
    string categoryName = Request.QueryString["categoryName"] as string;
    if (!string.IsNullOrWhiteSpace(categoryName))
    {
    BookContent.Controls.Clear(); // BookContent : Placeholder
    Control c = Page.LoadControl("~/UC/UC_Books.ascx") as UC.UC_Books;
    UC.UC_Books ucBook = new UC.UC_Books();
    ucBook.CategoryName = categoryName;
    ucBook.FillProduct(); //line 10
    BookContent.Controls.Add(ucBook); //line 11
    }

    }
    at the PageLoad of the Page, useBook contains data. but in the Page (view ), i don't see data. i think //line11 isn't execute or not true .

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,399

    Re: Setting Properties

    Please use appropriate formatting tags when posting code for the sake of readability:
    csharp Code:
    1. public void FillProduct()
    2.     {
    3.  
    4.         ProductsMN productsMN = new ProductsMN();
    5.         if (dlBook == null)
    6.         {
    7.             dlBook = new DataList();
    8.             dlBook.DataSource = productsMN.GetByCategoryName(CategoryName);
    9.             dlBook.DataBind();
    10.         }
    11.         else
    12.         {
    13.             dlBook.DataSource = productsMN.GetByCategoryName(CategoryName);
    14.             dlBook.DataBind();
    15.         }
    16.     }
    17.  
    18.     public string CategoryName { get; set; }
    csharp Code:
    1. protected void Page_Load(object sender, EventArgs e)
    2.     {
    3.  
    4.         if (!IsPostBack)
    5.         {
    6.         }
    7.         string categoryName = Request.QueryString["categoryName"] as string;
    8.         if (!string.IsNullOrWhiteSpace(categoryName))
    9.         {
    10.             BookContent.Controls.Clear(); // BookContent : Placeholder
    11.             Control c = Page.LoadControl("~/UC/UC_Books.ascx") as UC.UC_Books;
    12.             UC.UC_Books ucBook = new UC.UC_Books();
    13.             ucBook.CategoryName = categoryName;
    14.             ucBook.FillProduct(); //line 10
    15.             BookContent.Controls.Add(ucBook); //line 11
    16.         }
    17.  
    18.     }
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width