Problem with UserControl Property in a DataGrid after Postback

Discussion in 'ASP .Net Building Controls' started by Andreas Klemt, Jul 8, 2003.

  1. Hello,
    I have this

    page.aspx
    ----------
    <%@ Register TagPrefix="uc1" TagName="Userdetails" Src="Userdetails.ascx" %>
    ...
    <asp:datagrid id="dgTest" runat="server" autogeneratecolumns="False" >
    <columns>
    <asp:templatecolumn>
    <itemtemplate>
    My UserID is: <%# Container.DataItem("userID") %><br> <<<--- THIS WORKS,
    AFTER POSTBACK
    <uc1:Userdetails id="ctlUserdetails" userid='<%#
    Container.DataItem("userID") %> runat="server" /> <<<----- AFTER
    POSTBACK userid=0
    </itemtemplate>
    </asp:templatecolumn>
    </columns>
    </asp:datagrid>


    Userdetails.ascx
    -----------------

    Dim _userID As Integer
    Public Property ClientID() As Integer
    Get
    Return _userID
    End Get
    Set(ByVal Value As Integer)
    _userID = Value
    End Set
    End Property

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    Response.Write (_userID & "<br>")
    End Sub

    ---------------------------------------------------
    The first time the page gets loaded everything works fine.

    When I do a Postback, in my DataGrid the the userID's are ok with the first
    DataBound
    My UserID is: <%# Container.DataItem("userID") %>

    but in my UserControl Property Call

    <uc1:Userdetails id="ctlUserdetails" userid='<%#
    Container.DataItem("userID") %>

    the userid is =0. Why?

    Thanks for any help!
    Andreas
     
    Andreas Klemt, Jul 8, 2003
    #1
    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. Mike Dole
    Replies:
    3
    Views:
    6,284
    Karl Seguin
    Nov 17, 2004
  2. jon
    Replies:
    2
    Views:
    2,437
    Brock Allen
    Apr 29, 2005
  3. Fabiano
    Replies:
    2
    Views:
    638
    =?Utf-8?B?c3Jpbmk=?=
    Jun 3, 2005
  4. Big George
    Replies:
    1
    Views:
    430
    Eliyahu Goldin
    Dec 26, 2006
  5. Mark van Bree

    Postback problem with usercontrol in usercontrol

    Mark van Bree, May 30, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    176
Loading...

Share This Page