We help IT Professionals succeed at work.
Get Started

Saving repeater textbox value in a session

Camillia asked
Last Modified: 2012-04-22
I have a repeaer below. I bind to it from database.
1. User types something in the textbox area. This is page1.aspx
2. I click a button, go to another page. This is page2.aspx
3. I do something on that page2.aspx and go back to page1.aspx

Now, before I leave page1.aspx, I want to save the text user entered in repeater's textbox. How can I do this? This is what I have so far:

 <asp:Repeater runat="server" ID="rptProvider" OnItemDataBound="rptProivder_ItemDataBound">
              <asp:Literal runat="server" ID="lProviderId" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem, "Id") %>' ></asp:Literal>
              <asp:TextBox name="reason" runat="server" id="reason" style="max-width: 310px;" cols="41" rows="5" ></asp:TextBox>

Open in new window

I think when I click on the button on page1.aspx to leave that page, I need to loop thru the
repeater and save the textbox but not sure how to do that:

 foreach(RepeaterItem rptItem in rptProvider.Items)
              TextBox reason = (TextBox)rptItem.FindControl("reason");
              Literal reason = (Literal)rptItem.FindControl("lProviderId");
             //i have the ID for each row and the reason textbox. But how I save it in session?

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE