.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

CompositeDataBoundControl losing state on postback.

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net

*My apologies I posted this in the data controls forum but i'm cross posting here as it's more likely to get solved

I've seen a few examples of this online which seem to indicate my code is in the wrong order or I need to if-statement the dataBinding parameter but I nothing i've tried works.



Protected Overloads Overrides Function CreateChildControls(ByVal dataSource As System.Collections.IEnumerable, ByVal dataBinding As Boolean) As Integer 
        Dim count As Integer = 0 
        For Each dataItem As Object In dataSource 
            If ItemTemplate IsNot Nothing Then 
                Dim item As New GroupingRepeaterItem(dataItem, count) 
                ' need to add to controls collection 
                ' need to support <%# %> expressions 
            End If 
            If SeparatorTemplate IsNot Nothing Then 
                If count < CType(dataSource, DataView).Count - 1 Then 
                End If 
            End If 
            ' increase controls counter 
            count += 1 
    End Function


Many thanks in advance.

View Complete Post

More Related Resource Links

How do you save state of a toggle button after partial postback?


lets say you  have the toggle buttons from this page: http://www.filamentgroup.com/examples/buttonFrameworkCSS/

and you put it in a UpdatePanel AJAX...  so lets say on a partialpostback.. when you re-create teh controls on server-side, the state of whether or not those buttons were pushed is long-lost and gone.. so how then how do you remember those states?

Can I save each button state into viewstate or session state?  regenerate each button then call the javascript function to change its color-state depending on the session state variable?


Need to save unique state for each PAGE (losing current filters)



Nutshell: App has the ability to show same page with different settings at the same time, and the session state is too broad for that. I need to have a set of states, one for each page. 

My web page can display a scorecard that allows user to view or change scores for one or more possible sports teams (I changed actual business requirements to keep problem simple). For example, Team 1 can have positive score for some aspects of a game and negative for other aspects of a game. This page can show one or more teams side by side for comparison. The ability to add teams to the view is called filtering. There can be more than one view in a browser's tabs or new windows.

Here are my problems:

1. If the user presses Browser Refresh, they lose all current filters unless I use Session or TempData. Using Form Post does not work here. 

2. However, solution 1 doesn't work for multiple pages where the user wants to bring up 2 different views of the same page (for example, page 1 has Teams 1 and 2, and Page 2 has Teams 3 and 4). They cannot do this using Session or TempData. This only works if I pass the current filters to the controller via a Post Form Data data or in the Url.

3. The use of a url won't work because the data that needs to pass to the controller sometimes exceeds 500 characters.

I have googled this to no

losing gridview row value on postback


i have a global field called hotelId. i then have this piece of code that gets a value from gridview row:

        protected void gvHotel_SelectedIndexChanged(object sender, EventArgs e)
            if (Page.IsPostBack)
                int hotelId = (int)gvHotel.SelectedDataKey.Value;

the local variable is assigned to my global one, which gets passed to my method along with other variables. while stepping through i can see the value is set, but when i hit the submit button variabl is passed to another method except my hoteId. it gets lost...

Truly Understanding View State

This article provides a detailed understanding of the ViewState.

jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.

jQuery live() and ASP.NET Ajax asynchronous postback

The issue is that normally $(document).ready() is called when the DOM is ready to be manipulated. But this doens't happen after an ASP.NET Ajax asynch postback occurs.

This means that the initial jQuery bindings won't be automatically available after the asynchronous postback is over. I underline "automatically" here because my last post describes more possibilities, how this issue can be worked around.

Maintain HTML Radio Button Selection Inside GridView After Postback

Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.

Design Patterns - Using the State Pattern in C#

What is the State Pattern?

The State Pattern is a behavioral pattern that can be used to alter the behavior of an object at run time. As the state of an object changes, the functionality of the object can change drastically. This change of behavior is hidden from the Client and the Client interfaces with a wrapper object known as the Context. The State Pattern is a dynamic version of the Strategy Pattern.

view state vs request parameters


If  the view state is the data entered into the form fields then they are supposed to be available in the request parameters or request body. Then why would we need view state for?


SQL Server Session state problem.


Hi to all,

I have some things that I want to know. I am right now using a free asp.net webhosting ("somee.com"). The problem is that when I am visiting a page, there's a tendency that values stored in my session variables are lost. Therefore, it causes an error when the requested page is loaded.

1. I am thinking of using sessionState mode="SqlServer". Will it solve my problem?

Actualy Im working on it but Im having problems when connecting to the sql database.

2.  Is that a problem in the webhost?

3. Do free webhosting sites provide allow session state in the sql server?. Because ive tried it locally into my computer and error say's i should intall the ASP.NET Session State SQL Server version 2.0 or above.

View State Encryption


Hi All,

Why is it that I see the same hash value generated when I use different algorithms for viewstate encryption. I have added below lines to the web.config file

<pages viewstateEncryptionMode="Always"

browser gives jibberish when State manager (sql) is turned on


Hi all, we're testing our web app with a state manager so that we can do distributed rollouts. We're not getting any errors, but we are getting jibberish returned for every page request. 

(it won't even let me paste it in here)

HOw do I get it to serve the pages normally?


Custom Server Control Property not maintaining state


I have created a server control consisting of a TextArea and a div under it.  My goal is to create my own asp:TextArea type control.  the div is for a Character count of the text area and seems to work ok but i added a CharacterCountVisible property to the control that is always returning true.  See Proptery definition below


<Bindable(False), Category("Appearance"), DefaultValue("True"), Localizable(True)> Property CharacterCountVisible() As Boolean
        Return _CountBoxVisible
    End Get
    Set(ByVal value As Boolean)
        _CountBoxVisible = value
    End Set
End Property

Note the _CountBoxVisible variable is define inside the class as :

Dim _CountBoxVisible as Boolean = True

What I am trying to do is give the user/coder the option to show/utilize the char count feature.  Can make it disappear with textarea1.CharacterCountVisible = False but setting it to true will not make it display.


What am i missing





page postback problem with crystal report


Hi , i am creating crystal report with asp.net it is working showing data but  data is of two page its is take round trip action but report is not show 
until again i click on show button in this it is not propersly showing that data is how.

<br />
    <asp:Button ID="btnShow" runat="server" OnClick="btnShow_Click" Text="Show Report" />
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" DisplayGroupTree="False" EnableDatabaseLogonPrompt="False" /> CrystalReportViewer1.ReportSource = null; SqlCommand cmd = new SqlCommand(strcmd, c.con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); ReportDocument doc = new ReportDocument(); doc.Load(AppDomain.CurrentDomain.BaseDirectory + "\\rptQuotation.rpt"); doc.SetDataSource(ds.Tables[0]); // login info SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString); TableLogOnInfos crtableLogoninfos = new TableLogOnInfos(); TableLogOnInfo crtableLogoninfo = new Tabl

Security Briefs: View State Security


Effectively managing user state in web applications can be a tricky balancing act of performance, scalability, maintainability and security. The security consideration is especially evident when you're managing user state stored on the client. Here's what you need to know about view state security.

Bryan Sullivan

MSDN Magazine July 2010

CLR Inside Out: Handling Corrupted State Exceptions


There's a danger in using one-size-fits-all exception handling, and you need to know how to avoid it by being as specific as possible about how you handle errors.

Andrew Pardoe

MSDN Magazine February 2009

Foundations: Managing State With Durable Services


This month Juval Lowy tackles questions such as when to keep proxies and services in memory for better state management in long-running workflows.

Juval Lowy

MSDN Magazine October 2008

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend