After PostBack my UserControls Property doesn't work correct

A

Andreas Klemt

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top