ASP.Net/C# - storing repeater label text into a session variable or hash table etc?

Posted on 2009-04-21
Last Modified: 2012-05-06
I have a repeater and in the repeater I have a label.  I have this update ajax panel that is killing what I need to do.  So I need to somehow store to a table or something in session the control ID and the value and then be able to place it back into that control each time the page refreshes.
Question by:sbornstein2
    LVL 2

    Accepted Solution

    Have you considered using a hidden field?

    <input type="hidden" value="Value That You Need to Store" id="KeyName">

    This will sit on the page hidden from view, and you can simply update the value with your query, id, or any unique string field and then read it on page load and populate your table or somthing. It will retain the value you assign to it before the postback, so after the postback the value is persisted.

    You can extract the hidden field's value by using the Params collection in the Request object, using a code line like this:

    String strValue = Request.Params["KeyName"];

    I'm not sure about storing a table in this field, but i'm thinking your just after persisting some sort of value between postbacks?

    this page might help with a more detailed explanation - and examples of querystring.

    Author Comment

    so this is what I have.  I have a repeater and then the control has to be in the repeater.  So the repeater is going to create seperate client id values for this control.  The best thing would be if I could do a find control on the clientid but it is not working for some reason unless the namingcontainer is needed etc.    If I use a hidden input field would the value go away on postback?

    Author Comment

    if I dropped the input field into my repeater how would I populate it?  Is it request.forms or something?

    Author Comment

    i would also still need to do a find control or append something to the control so I know what control name to fill as I loop through the repeater.

    Author Closing Comment


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now