User Control properties

Discussion in 'ASP .Net Building Controls' started by Netvision Mail, Nov 25, 2003.

  1. Hi all,
    I'm a total newbie, so this might be stupid...
    Anyway, I've created an expanding tree of categories control, based on
    DataList.
    It works almost fine, but I can't make it return the value of the last
    category clicked.
    To be more specific, it does return it, but only the second time I click the
    category.
    For example, if I click category 5 and then 8, it shows 5 and clicking later
    on 3 shows 8.

    It goes like this:

    ..
    ..
    ..
    public property CategoryID
    Get
    if(ViewState("CurrentCategory") = Nothing)
    CategoryID = 1
    else
    CategoryID = ViewState("CurrentCategory").ToString
    end if
    End Get
    Set

    ViewState("CurrentCategory") = value
    End Set
    end property

    ..
    ..
    ..

    sub CategoriesDataList_ItemCommand(sender As Object, e as
    DataListCommandEventArgs)
    CategoryID = e.CommandArgument
    CategoriesDataList.DataSource = GetCategoriesTree(e.CommandArgument)
    DataBind
    CategoriesDataList.SelectedIndex = e.Item.ItemIndex
    End Sub

    The real big problem, as much as I could figure it out is that the
    CategoriesDataList_ItemCommand event is processed AFTER the Page_Load event
    of the parent page is. So, when i write something like

    [assume CategoriesTree is a CategoriesDataList control]

    msg.Text = CategoriesTree.CategoryID

    in the parent page, the value shown in msg is the old one (taken from
    ViewState bag).


    Thanks for any help,
    Igor.
     
    Netvision Mail, Nov 25, 2003
    #1
    1. Advertising

  2. Please see my response to your last post "Events Handling Order"

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx

    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    "Netvision Mail" <> wrote in message
    news:bq063q$ijc$...
    > Hi all,
    > I'm a total newbie, so this might be stupid...
    > Anyway, I've created an expanding tree of categories control, based on
    > DataList.
    > It works almost fine, but I can't make it return the value of the last
    > category clicked.
    > To be more specific, it does return it, but only the second time I click

    the
    > category.
    > For example, if I click category 5 and then 8, it shows 5 and clicking

    later
    > on 3 shows 8.
    >
    > It goes like this:
    >
    > .
    > .
    > .
    > public property CategoryID
    > Get
    > if(ViewState("CurrentCategory") = Nothing)
    > CategoryID = 1
    > else
    > CategoryID = ViewState("CurrentCategory").ToString
    > end if
    > End Get
    > Set
    >
    > ViewState("CurrentCategory") = value
    > End Set
    > end property
    >
    > .
    > .
    > .
    >
    > sub CategoriesDataList_ItemCommand(sender As Object, e as
    > DataListCommandEventArgs)
    > CategoryID = e.CommandArgument
    > CategoriesDataList.DataSource = GetCategoriesTree(e.CommandArgument)
    > DataBind
    > CategoriesDataList.SelectedIndex = e.Item.ItemIndex
    > End Sub
    >
    > The real big problem, as much as I could figure it out is that the
    > CategoriesDataList_ItemCommand event is processed AFTER the Page_Load

    event
    > of the parent page is. So, when i write something like
    >
    > [assume CategoriesTree is a CategoriesDataList control]
    >
    > msg.Text = CategoriesTree.CategoryID
    >
    > in the parent page, the value shown in msg is the old one (taken from
    > ViewState bag).
    >
    >
    > Thanks for any help,
    > Igor.
    >
    >
    >
    >
     
    Victor Garcia Aprea, Nov 26, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?YWJqb3Jr?=
    Replies:
    1
    Views:
    3,824
    Jeffrey Palermo
    May 5, 2004
  2. Nathan Sokalski
    Replies:
    0
    Views:
    916
    Nathan Sokalski
    Oct 17, 2005
  3. Max2006
    Replies:
    2
    Views:
    515
    Max2006
    Jul 13, 2007
  4. Adam M
    Replies:
    1
    Views:
    412
    Adam M
    Jan 23, 2008
  5. Nathan Sokalski
    Replies:
    0
    Views:
    213
    Nathan Sokalski
    Oct 17, 2005
Loading...

Share This Page