User Control Property Persistence - How do I get my property value to stay/come back to me?

I have a user control that's rendered in a data bound List View, for example:

<asp:ListView ID="ListBuildings" DataSourceId="ListDataSource" runat="server">
    <custom:Rater ID="Rater" BuildingId='<%# Eval("BuildingId")%>' runat="server" />

I set a custom property on my user control called BuildingId, but on post backs I'm not finding the BuildingId property set to what I set it to in the through the list view's databinding.

I can see that on postbacks the listview isn't getting re-binded, it's values are being persisted through viewstate. Why isn't my user control's BuildingId property value being persisted though?

Any input on how I might be able to set a custom property on a user control from within an item template for a data bound control, and then retrieve that value on further postbacks from events in the aformentioned user control would be really appreciated.



7/16/2008 11:00:48 AM 93655 articles. 6 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 50
Get it on Google Play
Get it on Apple App Store

In the user control inseta of keeping the value in a varibale keep it in the viewstate and u will find the value after postback

public int BuildingId
get{ return convert.ToInt32(viewstate["BuildingId"]);}
set{viewstate["BuildingId"] = value;}


Please mark the answer if it helped you
7/16/2008 11:16:34 AM
7/16/2008 11:44:40 AM

Similar Artilces:

Getting value of a property in Parent User control from a Child user control
I have a ChildUserControl that is loaded inside a ParentUserControl. The host page loads ParentUserControl.I would need to access properties in ParentUserControl from the ChildUserControl.Thanks for your time Here's some ideas: You can from the child access the parent and run findcontrol. child.parent.findcontroL("indyanguy1") child.parent.parent.findcontrol("indyanguy1") The trick is when you get your findcontrol working to cast the result to the object type your looking forHere I'm looking for a label so I cast to label then I can use the .Text property.Y...

Using property values of user control between two web forms.
Hi,I am stuck with a problem.I have a user control on more than one web form( say webform1 and webform2 ).The user control consists of several hyperlinks(say hyp1 and hyp2 ).When I enter values in webform1 and then click 'save' button , one of the property of user control (say ID ) is assigned some value. I want to use that value 'ID' in webform2 after the user clicks on hyp2. I dont think using Querystring will be useful because hyp1 is selected be default. It is not a compulsion for the user, that he has to click on hyp2..he can also click on other hyperlinks of the user control also...Ple...

Getting a web form's properties to a Custom User Control
Ok. This is hopefully a simple question that someone could help me out on. I've researched but only found out how to get a user control properties to a web form. Problem:  Anyway, I have created a custom user control (Help button with a menu extender) which will be used on several pages. The menu that extends from the button will not be static, so I will want to load the right data (from my xml file) depending on which page the help button is on. For example, my custom user control will be on pages news and the other on media. Now, when the user control loads on the news page, I need ...

Adding a property to a user control, setting property at design time, then using value in control markup
 I have made a custom control that outputs a bunch of html. I have added a property through the code behind like this:  private string sectionID; public string SectionID { get { return sectionID; } set { sectionID = value; } } This property is now showing up in Intellisense, and I can specify the value when adding the control to my page like this: <ccl:MyControl runat="server" SectionID="2" /> I now want to use this value in the markup that the control outputs. I thi...

user control
testUserControl.ascx  <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="testUserControl.ascx.cs" Inherits="testUserControl.testUserControl" %> <asp:Label ID="Label1" runat="server" Text="User control label"></asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />  testUserControl.ascx.csusing ...

How do I get the value of a user control property?
I would like to create a user control with some properties and assign values to those propeties.I would then like to access those values on the page that calls the user control.Thank you for your help. You can use the instance name of  the user control to call its properties.For example,a user control name is UserControl1 and it has the properties such as Text,Value,ListItem and so on,and you can call the properties as the following code.string strText = UserControl1.Text or UserControl1.Text = "This is a testing Text."string strValue = UserControl1.Value or UserControl...

Web User Control Default Property Value
I have a Web User Control (not a custom Server Control) on my page and I have a property set:         Public Property Enable_Export() As Boolean            Get                Return Export            End Get            Set(ByVal value As Boolean)            &nbs...

Access User Control properties from a Web Form
Hello, Can someone please let me know how I can access the properties of a web form from a user control? For example, I have a user control which contains an imagebutton, and I have "attached" this to the web form using the <%@ Register tag. However I would like to control the visibility of a particular control on the web form via the user control, but am unable to find out how I can do this. Any help will be much appreciated, Thanks for your time you can access the parent page's properties by using in the user control. page.controls or

Passing values to property in user web control
I have the following user web control: public class ServiceRequestListControl : System.Web.UI.UserControl { protected Infragistics.WebUI.UltraWebGrid.UltraWebGrid ServiceRequestGrid; private Program objProgram; private string m_TestString; private void Page_Load(object sender, System.EventArgs e) { bindServiceRequestGrid(); } private void bindServiceRequestGrid() { objProgram = (Program)Session["objProgram"]; if (objProgram != null) { // Get the list of service requests from the current objPro...

Web User Control property loses value on postback
I have a user control that seems to lose its property values on postback.  In the control, I have a property thats a datatable that populates a radiobutton list.  On the outside page, I've passed in the datatable by setting the property directly and by creating a method that sets in internally.  The control has a method that checks the selected value of the radiobutton list against the datatable and returns back a boolean.  Problem is when I call the function, the datatable is nothing. Below are the functions inside my user control.  Is there something about...

Set User Control Property from web form class
I am having a difficult time Setting the values of the properties in my User Control. My user control code follows: '---- tabs.ascx.vb ------------------- Public Class tabs Inherits System.Web.UI.UserControl Public tab1Name As String Public tab1href As String Public Sub New() End Sub Property t1Name() Get Return tab1Name End Get Set(ByVal Value) tab1Name = Value End Set End Property Property t1href() Get Return tab1href ...

Passing same property value to multiple Web User Controls
I am trying to write a Web Form (aspx) page that accepts QueryString parameters for a Web User Control to display and a LocalValue that is common across all ascx pages. The following code works: Private Sub ShowControl(ByVal AscxName As String, ByVal LocalValue As String) Dim uc As UserControl uc = LoadControl(AscxName) Select Case AscxName Case "WebUserControl1.ascx" DirectCast(uc, WebUserControl1).CommonProperty = LocalValue Case "WebUserControl2.ascx" DirectCast(uc,...

Cannot get user control property to persist across postbacks
Hi, I have a user control "LoginBox" which provides the user with a username and password which is authenticated against a database. Problem is that I can't get the public properties of the user control to persist across postbacks. Whenever the property values for "isAuthenticated" and "UName" are changed in the user control this is not reflected in the master page- I just get the default values (false and null respectively).Where have I gone wrong? Here's my code: Main Page 1 using System; 2 using System.Reflection; 3 using Sys...

Cannot get a property value sent by the user on my Web Service
 Dear all, I developed a web service whose methods had to be the same as in our partners web service. The web service has a property "Credentials" of type NetworkCredentials : private NetworkCredential _Credentials; public NetworkCredential Credentials { get { return _Credentials; } set { _Credentials = value; } }  For testing a partner's web service I instantiate his ws and I pass the credentials throu the property:  WebService wpSynch = new WebService (); wpSynch.Credentials = new NetworkCreden...

Web resources about - User Control Property Persistence - How do I get my property value to stay/come back to me? -

Persistence of vision - Wikipedia, the free encyclopedia
In contrasting persistence of vision theory with phi phenomena, a critical part of understanding that emerges with these visual perception phenomena ...

Persistence - Goal and Habit Tracker on the App Store on iTunes
Get Persistence - Goal and Habit Tracker on the App Store. See screenshots and ratings, and read customer reviews.

POV: Persistence of Video - YouTube
My name's Alan. I'm an author, songwriter, and artist who is now daily vlogging. I co-founded DFTBA Records with Hank Green in 2008 and currently ...

Natures Organics' persistence beats resistance
Justin Dowel's father was initially reluctant to let him join the family business, Natures Organics, before he'd established himself in another ...

Neoconservatives despair over US persistence with diplomacy
They argue that America should be going after Syria and Iran, which are Israel's enemies but also the enemies of the US, writes Michael Gawenda. ...

The remarkable persistence of power and privilege
A new study finds social status rippling across the centuries

Persistence pays off for Canterbury Bulldogs hooker Damien Cook
Damien Cook always thought he'd figure prominently in Canterbury's playoff campaign.

CPC leadership stress persistence in "mass-line" campaign
CPC leadership stress persistence in "mass-line" campaign People's Daily Online "The ultimate score of the campaign is subject to people's ...

The Persistence of Gay Memory -
The question of whether or not former Tennessee congressman Harold E. Ford Jr. will challenge incumbent Kirsten Gillibrand for the Democratic ...

Avoiding image persistence on Apple displays
This article explains how to avoid image persistence on certain Apple displays, and describes the unique characteristics of IPS display technology. ...

Resources last updated: 1/16/2016 1:52:26 PM