Solved

Retaining values on postback

Posted on 2004-04-09
8
1,478 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
Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

 
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 250 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

696 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