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

  • Home
  • SEARCH
  • 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 6596583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:05:42+00:00 2026-05-25T18:05:42+00:00

Let say that we have an object class Entity { public string ID {get;

  • 0

Let say that we have an object

class Entity
{
    public string ID {get; set;}
    public string Name {get; set;}
}

I want to bind properties to two textboxes on a page something like this:

<asp:FormView ID="FormView" runat="server">
  <ItemTemplate>
    <asp:textbox ID="TextId" Text='<%# Bind("ID") %>'/>
    <asp:textbox ID="TextId" Text='<%# Bind("Name") %>'/>
  </ItemTemplate>
</asp:FormView>

and then write this in code behind

public EntityObject
{
    get { return ViewState["Entity"] as Entity; }
    set { ViewState["Entity"] = value; }
}

protected override void OnInit(EventArgs e)
{
    if (EntityObject== null)
        EntityObject= new EntityObject();

    FormView.DataSource = new[] { EntityObject };
    FormView.DataBind();
    base.OnInit(e);
}

And when I enter values in textboxes I expect EntityObject to have these values in properties when page reloads after PostBack, but properties are always null.

  • 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-25T18:05:43+00:00Added an answer on May 25, 2026 at 6:05 pm

    Sadly to say that, but ASP.NET does not support two-way binding to .net objects…
    instead you can use something like “manual binding” on every post back (here AddIncomeSources is RepeaterControl)

    public List<Income> AdditionalIncomeList 
    {
        get { return ViewState["AdditionalIncome"] as List<Income>; }
        set { ViewState["AdditionalIncome"] = value; }
    } 
    
    foreach (RepeaterItem item in AddIncomeSources.Items)
    {
        var amount = (TextBox)item.Controls.Cast<Control>().First(c => c.ID == "Amount");
        var document = (DropDownList)item.Controls.Cast<Control>().First(c => c.ID == "Document");
        AdditionalIncomeList[item.ItemIndex].Amount = amount.Text.ToDouble();
        AdditionalIncomeList[item.ItemIndex].IncomeDocument = document.SelectedValue;
    }
    
    AddIncomeSources.DataSource = AdditionalIncomeList;
    AddIncomeSources.DataBind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a domain object that looks like this: @Entity @Indexed public
Let us say we have a simple business object: class SimpleBO { public string
Let's say that I have this: public abstract class myClass<T> : Ob<T> where T
Let's say that I have a boost::variant<std::string, int> myVariant; In this object I keep
Let's say that I have a class Foo: public class Foo { public static
I have array of Objects (let say that class name is Snap) Snap. Is
Let's say that you have overridden an object's equals() and hashCode() methods, so that
Let's say i have a griffon object that needs to be part of the
Let's say I have a List object and an iterator for that list. Now
An interesting question arose today. Let's say I have a .NET object that implements

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.