How To Persist The Data From A Repeater After Postback

Jul 1, 2010

I have a repeater that displays financial data and prices for various stocks.

On this page, I also have an "export" button that needs to take the data ~on the screen~ and convert it into a CSV for the user.

The problem is, after I databind my list of "Stock" entities:

List<Stock> stocks = GetStocks()
rptStockList.DataSource = stocks;
rptStockList.DataBind();

The data is not persisted on postback.

Also, the data on this page is constantly being updated via an UpdatePanel and a Timer control (being re-databound each time). Every 30 seconds the prices displayed for the various stocks in the repeater control change.

Now, I have a linkbutton that has a click event method in the code-behind that is supposed to export the ~data on the screen~ for the user. I need to grab the current values for the list of stocks last databound to the repeater. I can't simply go grab the latest values from the database because those will have been changed in the time between the last refresh.

protected void lbtnExportStocks_Click(object sender, EventArgs e)
{
// No longer have the stock data used in the repeater control
ExportStocksToExcel();
}

I know that ASP.NET doesn't persist the datasource for the repeater on post-back but I need to still be able to either re-construct this list of Stock entities so I can send them the CSV or I need persist it in some way.

I don't want to do anything that is too heavy handed in terms of performance because during certain days of the week this application can have some heavy usage.

What is the proper solution to this type of situation? Should I iterate through the Repeater's "Items" collection and reconstruct the Stock entities?

View 4 Replies


Similar Messages:

Forms Data Controls :: Persist Images In Gridview After Postback?

Oct 5, 2010

I have a grid view whose 1st column is Image Field. Now I assign 1 out of 4 images to each row at runtime. I have this gridview in ajax updatepanel. Now how can i persist the images in the first column after a postback.

View 6 Replies

Forms Data Controls :: Persist The Gridview Values After Postback?

Oct 18, 2010

Im binding the gridview in page load.After i click the link button in the gridview it displays another gridview.I have a checkbox in that gridview.I check some of the checkboxes.while i click the save button i want to get that checkbox state whether its checked or not.Bt for me its showing no records in the grid.How do i persist my data and get the checbox's state.

View 3 Replies

Web Forms :: How To Persist The State Of Object On Postback

Jan 26, 2011

I bind textbox to a property of an object. After running the app, if the value of textbox is changed, I expect the object to update this property .This does not happen. I also understand that I am recreating the object from viewstate on postback, which is wrong. how to persist the state of object on postbacks all.

[Code]....

View 1 Replies

C# - Persist Silverlight MediaElement Playing On Postback

Nov 18, 2010

I am trying to figure out how to persist the playing of a Silverlight MediaElement playing within a Silverlight User Control embedded in an ASP.NET during postback.

The scenario goes:

Have a media player on a site, press play, continue navigating through site while the music continues playing.

What it does right now:

Obviously the object gets loaded anew on each postback or page redirect (even if it's back to the same page IE: default.aspx).

I've seen samples of how to persist the state of a Control on postback and even complex data through cross-page postback. But nothing that covers my specific case.

Other particulars:

Silverlight 2
ASP.NET
C#

My default.aspx:

[code]....

View 1 Replies

JavaScript - Persist Dynamic Inserted Content Across Postback?

Feb 3, 2011

I have a div lets say :

<div id="foo">
</div>

Now I inserted some html content inside this div on some button click(without postback) . Now when I perform a postback on some action say on server control submit button , I want the html(which I inserted via javascript) be persisted in the foo div. Right now I am thinking to take an hidden input server control and when the form will be submitted I will insert the content of foo div in that hidden control, the next time when the page loads after the postback I will fill the foo div with the content inside the hidden field. Am I going with correct approach or is their any other good approach which I should opt ?

View 1 Replies

State Management :: Session Does Not Persist After Postback On Deployment

Nov 22, 2010

I ve been searching for this on various forums and came through a number of supposed solutions which didnt work for me.

My web form works perfectly for me when on development and after publishing on IIS but when I try to access remotely the session value is always null.

I do these things in the following order and when accessing remotely I always get the exception i throw when session is null.

I debugged it and my list is never null when reaching the assignment point.

[code]....

in webconfig I have the following tag which I saw as an answer in many forums

<sessionState mode="InProc" cookieless="true" timeout="200" />

View 1 Replies

Web Forms :: How To Persist Or Hold Multiple Values Across PostBack

Jan 17, 2014

i want to hold data at runtimeEx-I have a 3 Services A,B,C and in A,B,C contain services list,then if user select A service and 3 services in a A Listagain user select B service and 2 services in a B Listand again user Select C Service and select 1 services in a C listSo How i can hold data A,B,C services ID'S value with respect to services listID'S value at runtime.

View 1 Replies

State Management :: How To Persist A Class Object When Page PostBack

Oct 5, 2010

i have created a user control UserControl.ascx, in Code behind file of UserControl.ascx i have created an object of a class MyClass.cs,

Like

if(!Page.IsPostback) {
objMyClass= new MyClass();
}

but when i click on button of UserControl.ascx page and try to access objMyClass object then it set as null, so how to persist MyClass object when page PostBack, i wanted to keep object persist till the user access the page, when user goes out of this page then object should distroy?

[code].....

View 9 Replies

State Management :: How To Make A Custom Property Or A Page Persist Across Postback

Sep 29, 2010

I have an object to hold some specific state information in my web application - I pass it back & forward between pages by making it a property of a basepage which works fine, but I lose it on postback.

Is there any way to persist this property without manually adding & reading it again from viewstate?

View 3 Replies

C# - Repeater Within Repeater (ajax Based Web App) - Cannot Use Any Postback Methods

Jun 23, 2010

For the solution, I cannot use any postback methods, because this is all working through ajax. The solution need to be implemented in the asp.net code. I have a List<WebPage> that contains a list of Links (List<Link>) and I need for all the links to bind repetitive information such as page title, id, url. Here is my current repeater.

<div id="result">
<asp:Repeater runat="server" id="results">
<Itemtemplate>
<asp:Repeater runat="server" datasource='<%# Eval("Links") %>'>
<Itemtemplate>
<tr class="gradeX odd">
<td><%# Eval("Id") %></td> //property of WebPage (part of results repeater)
<td><%# Eval("Title") %></td> //property of WebPage (part of results repeater)
<td><%# Eval("Url") %></td> //property of WebPage (part of results repeater)
<td><%# Eval("URL") %></td>//Property of Link
<td><%# Eval("URLType") %></td> //Property of Link
<td><%# Eval("URLState") %></td> //Property of Link
</tr>
</Itemtemplate>
</asp:Repeater>
</Itemtemplate>
</asp:Repeater>
</div>

of course this doesnt work, how can i do this?

View 2 Replies

Web Forms :: Repeater Losing Data On Postback

Jul 3, 2010

Private Sub UpdateOffensiveStats()

Repeater losing data on postback

View 2 Replies

Forms Data Controls :: Getting Repeater's Field Value Without Postback?

Nov 28, 2010

i use div and repeater to show categories for searching part. there is a div. when iclick it, repeater opens and if i select a category its name shows on div. this part is ok. Now i do searcing. so i have to take the span's value(or repeater's value).

View 2 Replies

Custom Server Controls :: Custom Control's Children Do Not Persist Contents After Postback

Feb 25, 2011

I have created a really simple custom control to render panels into a page. The code is below. When I use my control and add any webcontrol to it, after each page postback the contents of these child controls vanishes.

I must have missed something really simple but run the example to reproduce this. Can anyone please enlighten me as to why the controls are being 'emptied' of their contents, and how I stop this occuring?

Here is the code for the control

[Code]....

And here's how I am using it in a sample page:

[Code]....

[Code]....

View 16 Replies

Forms Data Controls :: Firing Postback From Repeater Row Click?

Jul 19, 2010

I have a repeater which contains a hidden link button that fires when I click a row in my repeater.

Here is the markup for my repeater:

<div id="divResults" style="height: 290px; overflow-y: auto;">
<asp:Label ID="lblNote" runat="server" Text="Note: select a row to edit."></asp:Label> [code]...

Here is the javascript thats added to each row in the rptLocations_ItemDataBound:

Row.Attributes.Add("onclick",
"javascript:__doPostBack('ctl00$mainContent$rptLocations$ctl0" + (e.Item.ItemIndex + 1).ToString() +
"$lbtn_SelectRow','')");

When I click the repeater row it fires the SetLocationControls method. As you can see my repeater is wrapped in a DIV of height 290px. When the are more than 9 rows in my repeater you have to scroll the div down to view this row. When I click this row it does the postback but doesn't fire the SetLocationControls method. I've had a look in the source it's created the click event to the repeater row like all the other rows. why this method isn't firing on the rows that aren't initially visible in my DIV?

View 21 Replies

Forms Data Controls :: Change Literal In A Repeater After A Postback?

Jul 9, 2010

I want to change the value of a literal within a repeater ItemTemplate after postback, based on a value detected at postback.I can't render the whole repeater again though I think because it's actually a radio button in the control that inititates the postback and so I need that control / value to be persisted.

View 1 Replies

Repeater Databound Loses Data & Event On Postback - Is There A Best Practice Solution

Oct 7, 2010

Currently struggling with a problem that I've encountered variations on in the past. At the moment a worthwhile solution escapes me, but it seems such an obvious issue that I can't help wondering whether or not there's a "best practice" approach I should adopt.Without code, here's the issues in a nutshell:


page has databound control (a repeater) which isn't populated until user inputs data and clicks a button.Repeater item template contains a buttonUser clicks button, page posts back. On load, the repeater is actually empty so event is never handled because the originating control no longer existsGo back to the beginning of wretched cycle I've confirmed that this is the problem because if you provide the repeater with some static data on page load, everything works fine. But of course that's no use because it has to be populated dynamically.Is there a commonly approved way round this headache? I can store the data in session and re-use it on page load, but it seems terribly clumsy.

View 2 Replies

Forms Data Controls :: Property Of Custom Control In Repeater Is Null On Postback?

Jan 12, 2011

A common problem in repeater controls where you want to display data for update (like a list of user phone numbers that can be updated and submitted back to the database) is where to store the database unique row identifier. So, I created a custom Textbox control that I've added a Data property to. I populate this data property with the unique row id. The problem is that when I post back the list and go through the repeater items the control's data property is null. The custom control looks like this:

[Code]....

The tag in the repeater looks like this:

[Code]....

I have a custom checkbox with the same data property and it works fine. I actually put in the same repeater with the textbox control and the checkbox control have the row id on postback but the textbox did not. Is there some limitation on the textbox control that might be causing this.

View 1 Replies

Repeater Is Updated Without A Postback?

Mar 19, 2010

I've got a repeater which is placed inside an updatepanel. When the user enters a new value, the repeater is updated without a postback. Is it possible to get the row that was updated in JQuery so that I can place an effect on it to make the change less subtle? For example, I'd like to fade a new color in on just the row that was changed.

View 3 Replies

Getting The Postback Event Of A Control Within A Repeater

Feb 2, 2010

I have a link button embedded in a repeater but I can't figure out how to get the exact postback reference of the control so I can access it in JavaScript. Bear in mind this code is a little pseudocodish/partial anyway and I am fixing someone else's code.

I just can't seem to get the right postback JavaScript - the form posts but doesn't fire the item command event or pass the

Protected Sub repResults_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repResults.ItemDataBound
Dim hypInsertBCard As LinkButton = e.Item.FindControl("hypInsertBCard")
Dim myPostBackOptions As PostBackOptions = New PostBackOptions(hypInsertBCard)
myPostBackOptions.AutoPostBack = True
myPostBackOptions.RequiresJavaScriptProtocol = True
myPostBackOptions.PerformValidation = False
Dim strRef As String = ClientScript.GetPostBackEventReference(myPostBackOptions)
hypInsertBCard.Attributes.Add("onkeypress", strRef)
End Sub

View 1 Replies

C# - How To Persist Graph Data For Website

Nov 1, 2010

We've worked out some of the tasks on our website can be efficiently solved by maintaining the data using a graph structure. But we don't have much of an idea about how the graph is best persisted. Further we want to write and read simultaneously in an efficient manner in out asp.net app so it needs to handle multiple threads. It doesn't need to be super fast but it needs to be scalable to handle potentially millions of nodes.

I don't want to hack my own system and have heard of Neo4j. Lots of Java developers seem to recommend it to one another. Obviously I'm on the .Net platform and prefer to not have to switch.

What are the available options, particularly on the .Net platform?

View 1 Replies

LinkButtons In A Repeater Within An UpdatePanel Are Not Triggering A Postback

Sep 13, 2010

My page contains a Repeater that is loaded with data asynchronously as the data becomes available, using an UpdatePanel to manage the asynchronous requests.The page contains something a little like this:

<asp:UpdatePanel ID="DataUpdatePanel" runat="server">
<ContentTemplate>
<table>
<asp:Repeater ID="RepeaterBlock" runat="server">
<HeaderTemplate><thead><tr><th>Name</th><th>Status</th><th class="empty"></th></tr></thead></HeaderTemplate>
<ItemTemplate><tr>
[code]...

The problem being that the LinkButton does not appear to trigger a postback of any kind- there is no visible response to clicking on it and putting a break point on the event listener in the codebehind, it is never triggered.
hat the linkbuttons ceased working.

View 2 Replies

VS 2005 - How To Persist Gridview Data After Crosspage Posting

Jul 25, 2010

how can i persist gridview data after crosspage posting? It seems that every time i visit another page and get back to page the entire gridview data and page index were reset.

View 6 Replies

Web Forms :: Persist Data Using Cookies Inplace Of Session?

Mar 10, 2010

I need to persist data between pages.I tried using session but the value is not saving.

Should using cookies be a better option? If so give a small example of transfreing and saving data between pages.

View 20 Replies

Forms Data Controls :: How To Print A Message In Child Repeater If No Data Corresponding To Parent Repeater

May 12, 2010

protected void Page_Load(object sender, EventArgs e)

[Code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved