Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6185545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:43:55+00:00 2026-05-24T01:43:55+00:00

On Page_Load , I am binding a Repeater using EF4. The repeater contains some

  • 0

On Page_Load, I am binding a Repeater using EF4. The repeater contains some text boxes which are populated at the start but the user could edit. How can I read these text boxes on a later postback?

page.aspx (extract):

<asp:Repeater ID="repOrders" runat="server">
  <ItemTemplate>
    <p>
      <%# Eval("Id") %> -
      <asp:TextBox ID="txtName" Text='<%# Eval("Name") %>' runat="server">
      </asp:TextBox>
    </p>
  </ItemTemplate>
</asp:Repeater>

page.aspx.cs (extract):

protected void Page_Load(object sender, EventArgs e) {
  using (var ctx = new Ctx()) {
    var ds = ctx.Orders;
    repOrders.DataSource = ds;
    repOrders.DataBind();
  }
}

protected void lnkCheck_Click(object sender, EventArgs e) {
  Response.Write(((TextBox)repOrders.Items[0].FindControl("txtName")).Text);
}

The problem is, when I click lnkCheck, the Repeater re-populates from the database first so any user changes to the textboxes are lost.

And if I put if (IsPostBack) return; in Page_Load then the Repeater is empty.

How can I get around this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:43:57+00:00Added an answer on May 24, 2026 at 1:43 am

    Only populate the repeater if not a postback. As long as viewstate is enabled for the repeater your data will be persisted.

     protected void Page_Load(object sender, EventArgs e) {
    
        if(!IsPostBack)
        {
         using (var ctx = new Ctx()) {
            var ds = ctx.Orders;
            repOrders.DataSource = ds;
            repOrders.DataBind();
          }
        }
    
        }
    

    How are you raising the ‘later postback’ to read the text values from the repeater? Usual preference would be to raise an the itemcommand from the repeater and then use find control to get the value of the textbox in the item template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a repeater with which I want to use to show a user
I have a query expression which I am binding to a GridView in Page_Load.
I develop user control Date of Birth, which contains 3 DropDownList. I need to
I have a List (Of MyObject) binding to a GridView in the Page_Load event.
Page_Load Calls more than once (4 times in my case) in FireFox but in
I have a grid table, which I do data binding on page load if
This error occurs when data binding a repeater: SQL Server does not handle comparison
Hi have a repeater which is inside a gridview. when i bind the data
In ASP.NET, I am exporting some data to Excel by simply binding a DataSet
I have a usercontroll which accepts some parameter and I need to insert this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.