Ask a Question related to ASP.NET General, Design and Development.
-
Andreas Klemt #1
After PostBack my UserControls Property doesn't work correct
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 Guest
-
UserControls and Collections Property
With a Web *UserControl* (not composite control) how do you make a collection-- either custom col derived from CollectionBase or a .NET 2.0 generic... -
Control Not remembering property on postback
Hi, where in the lifecycle / events you reading/writing the value? Init, Load, postback event, PreRender...? -- Teemu Keiski ASP.NET MVP,... -
Property not set on postback
I have a very basic control. In the ChildControls I have added a response.write to write a property I have set. I does it on the first display but... -
Using ID property for controlling controls in UserControls
Sorry, my problem was there where a was thinking line 154 I have to us TablePrincipal.FindControl("..." If I adding controls into a... -
Dynamic creation of UserControls - Problem with postback
I have created a UserControl, and I am dynamically adding it to each row of a datagrid with a sub called by the datagrid's 'OnItemDataBound'. That...



Reply With Quote

