locked
usercontrol inside another usercontrol RRS feed

  • Question

  • User-1648281042 posted

    Hi, I'm having a strange problem - I have a usercontrol which only shows data (no editing involved) and inside it another usercontrol which is supposed to get a certain value from the first one.

    Everything was working fine until I moved to asp.net 2.0 and tried to connect it to objectdatasource. Here is the relevant code:

     

    1    Partial Class ascx_main_pages_standard_index_item
    2        Inherits System.Web.UI.UserControl
    3    
    4        Private _article As Integer
    5    
    6        Public Property article() As Integer
    7            Get
    8                Return _article
    9            End Get
    10           Set(ByVal value As Integer)
    11               _article = value
    12               textbox1.text = value
    AudioBox1.article = value 13 End Set 14 End Property 15

    The first usercontrol works just fine except for firing the second one (audiobox1)

     I also tried to use

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    AudioBox1.article = _article
    End Sub

     Which doesn't work either. What am i doing wrong???

    Thursday, March 6, 2008 5:15 AM

All replies

  • User481221548 posted

    Hello Nestu

    Where is "AudioBox1" placed in?
    Compare the executing cycle of your get- or set accessors.

    I bet its an lifecycle problem.

    Saturday, March 8, 2008 6:49 PM
  • User-1648281042 posted

    Thanks for replying

    AudioBox1 is an instance to another userControl (in another .ascx file)

    I assume you are right because the value which is passed to the audiobox control is 0 (zero), so it must be a lifecycle issue. but as i said, on asp.net 1.1 it worked OK... and also, the other controls (like textbox1) work just fine, which means that the value of the property "article" is set.

    thanks again for any help...

    Sunday, March 9, 2008 9:57 AM
  • User481221548 posted

    Hello Netsu

    Go on with debugging and tracing, that will solve your lifecycle problem.

    Monday, March 10, 2008 5:55 AM
  • User-1648281042 posted

    Hi Peter, thanks for your help

    I did some debugging and it was indeed a problem of life cycle, so i solved that one, but the problem continues - in my usercontrol i have an sqldatasource which i want to bind to a repeater according to the property which is passed to the usercontrol.

    this is the code i use:

    Private _article As Integer

    Public Property article() As Integer

    Get

    Return _article

    End Get

    Set(ByVal value As Integer)

    _article = value

    End Set

    End Property

    Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)

    e.Command.Parameters("@ID_article").Value = _article

    End Sub

     

    this is where the problem is - the sqldatasource doesnt work. if i change _article to some number like 892 it works fine (binds to the row that has id of 892)

    when i put a breakpoint i can see that value of the parameter works fine - _article has the correct value according to my table. so why is the sqldatasource not binding??

    Wednesday, March 12, 2008 7:27 AM
  • User481221548 posted

    Hi Netsu

    You set the Breakpoint at the "e.Command...."-Line?

    Monday, July 21, 2008 1:24 PM