?
Solved

Retaining values on postback

Posted on 2004-04-09
8
Medium Priority
?
1,482 Views
Last Modified: 2008-03-03
I have a repeater control.
on every postback, I do the following in my aspx.vb :

rptListing.HeaderTemplate = New RenderExecutionResourceList(ListItemType.Header)
rptListing.ItemTemplate = New RenderExecutionResourceList(ListItemType.Item)
rptListing.AlternatingItemTemplate = New RenderExecutionResourceList(ListItemType.AlternatingItem)
rptListing.FooterTemplate = New RenderExecutionResourceList(ListItemType.Footer)
--Databinding() call happens here
-----------------------------------------------------------------------------------------------------------------
Public Class RenderExecutionResourceList
    Implements ITemplate

    Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn
        Dim lc As New Literal
        Select Case TemplateType
            Case ListItemType.Header
                lc.Text = "<Table border=0 cellpadding=1 cellspacing=1 "
                lc.Text &= "class=ToDoListTable width=100%>"
                lc.Text &= "<tr>"................. and so on
            Case ListItemType.Item
                AddHandler lc.DataBinding, AddressOf ExecutionResourceListItem_Databinding
            Case ListItemType.AlternatingItem
                AddHandler lc.DataBinding, AddressOf ExecutionResourceListAltItem_Databinding
            Case ListItemType.Footer
                lc.Text = "</table>"
        End Select
        container.Controls.Add(lc)
    End Sub
-----------------------------------------------------------------------------------------------------------------
    Private Sub ExecutionResourceListItem_Databinding(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim lc As Literal
        lc = CType(sender, Literal)
        Dim container As RepeaterItem
        container = CType(lc.NamingContainer, RepeaterItem)
        Dim currID As String
        currID = CType(DataBinder.Eval(container.DataItem, "ID"), String)

        lc.Text = "<tr id=row" & currID & ">"
        lc.Text &= "<input type=text size=6 id=""txtAS" & currID & """ class=""smalltextleft"" value=" & DataBinder.Eval(container.DataItem, "ProjEnd") & " onfocus=""this.blur()"" onclick=""JavaScript:updateWritein('txtAS" & currID & "'); callDiv('calspace')"">"
       lc.Text &= "</td></tr>"
    End Sub

End Class
-----------------------------------------------------------------------------------------------------------------

As you can see, I cant put these values in session variables since there could be 1 record or 500.
And I tried using server controls, but they are too expensive - page takes pretty long to load.
The user will be entering his date and could sort or something that would cause the page to postback.
I need to save the dates.

Any ideas ????
0
Comment
Question by:PBWMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10794242
I just answerre this question under another topic. The inputs are sent back during postback and are available through the request object.
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 10794675
what are you actually want to store in the session obejcts ? why don't you store the whole datasource object in the session obejct
after each operation ( sort, delete or whatever ) you can set the result datasource in the session and then get it
as gregoryyoung said you can get the variables from the request.form collection but as you use repeater control the keys are not normalized e.g. repeater:_ctl0:literal0

HTH
B..M
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10794808
incorrect B..M the values in question are being outputted as html <input>

        lc.Text &= "<input type=text size=6 id=""txtAS" & currID & """ class=""smalltextleft"" value=" & DataBinder.Eval(container.DataItem, "ProjEnd") & " onfocus=""this.blur()"" onclick=""JavaScript:updateWritein('txtAS" & currID & "'); callDiv('calspace')"">"
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 28

Expert Comment

by:mmarinov
ID: 10794816
:-) gregoryyoung, so why don't you try to accept them directly to see if you will grab them as they are nested controls in the repeater web control ;-)
B..M
0
 
LVL 9

Expert Comment

by:malharone
ID: 10795031
use session variables! An easy solution
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10795309
B..M are you suggesting that .net is going in and finding his html string (placed in a literal) locating his ID= and changing it to something else ?! He does not need to access the literal control as you suggest only the actual value which was stored in the input. I would be willing to wager a significant amount of money that this is producing html with the <input> named as he has it. Renaming does not happen on text within literals I am POSITIVE of this... Of course although MSDN will back me up I am sure PBWMan could tell us for sure ...

As for Session variables they are  fairly easy they are a bit of a waste of resources it being the page is taking the time and bandwith to upload these values back to the server. Also if someone were in process of editting only the request object would know of this edit.

btw: thanks B..M I have accepted numerous LITERAL controls output through repeaters nested controls etc. Remember that a LITERAL writes its output directly and is not subject to things like you mention.
0
 
LVL 1

Author Comment

by:PBWMan
ID: 10797316
Gregoryyoung is right.
Im returning my entire table, tr, td and textboxes in plain HTML.

The user sees 50-100 rows of data and each row has a textbox.
When the user clicks the textbox, a calendar pops up and the user can select his date.
When he does this, the corresponding row has a checkbox which gets checked.

I want to save these date values as they are on every postback.
For example, the user selects 5 dates for 5 rows, and then sorts a particular column header.
My code will postback and will then build this entire HTML again - so basically I lose all the user entered data.
I cant store these values in session - since there can be as many as 500 rows.

I hope you'll understand my question better now.
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 10801659
you can get the changed values off of the request object PBWMan ... the browser sends up all inputs etc on the form.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question