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 7953819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:14:44+00:00 2026-06-04T03:14:44+00:00

I have a formview, connected to an objectDataSource. It’s a pretty easy code in

  • 0

I have a formview, connected to an objectDataSource.

It’s a pretty easy code in the “EditItemTemplate” of the formview, implemented in the .aspx class:

<EditItemTemplate>
    Var1: <asp:TextBox ID="txtVar1" runat="server" Text='<%# Bind("var1") %>'  />
    Var2: <asp:TextBox ID="txtVar2" runat="server" Text='<%# Bind("var2") %>'  />
    <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="ButtonSave_Click" />
</EditItemTemplate>

When pressing “save” the data of “var1” and “var2” passes with the object to the next update method, that is implemented in the business logic class:

[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
public void UpdateMyObject(MyObject updatedObject)
{
    if (updatedObject.EntityState == EntityState.Detached)
            mContext.MyObjects.Attach(updatedObject);
        mContext.ObjectStateManager.ChangeObjectState(updatedObject, System.Data.EntityState.Modified);
        int numberOfAffectedRows = mContext.SaveChanges();
        if (numberOfAffectedRows == 0)
            throw new DataNotUpdatedException("No object updated!");
}

The thing is that I need to pass a 3rd variable from the aspx to the business logic, without exposing it to the user through a textbox. It’s a Guid and there is no need to change it.
With the current code, the Guid that is assigned to the “updatedObject” is only zeros and not the original Guid of the object, that it has and would have passed if I had binded it to a textbox, using a <%# Bind(“entryGuid”) %>.

So, my question is how can I pass this Guid (or any other variable) to the business logic layer, without the need to expose it? Is there an elegant way to bind data to the updated object not through a textbox?

Thanks!

  • 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-06-04T03:14:45+00:00Added an answer on June 4, 2026 at 3:14 am

    Since @tzerb’s answer left out an example, I thought I’d provide one.

    <EditItemTemplate> 
        Var1: <asp:TextBox ID="txtVar1" runat="server" Text='<%# Bind("var1") %>'  /> 
        Var2: <asp:TextBox ID="txtVar2" runat="server" Text='<%# Bind("var2") %>'  /> 
        Var3: <asp:HiddenField id="hdnVar3" runat="server" Value='<%# Bind("var3") %>' />
        <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="ButtonSave_Click" /> 
    </EditItemTemplate> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the problem is that I do have an ASP.NET TextBox in a FormView with
I have a fairly simple form: <asp:FormView> <EditItemTemplate> <asp:LoginView> <RoleGroups> <asp:RoleGroup roles=Blah> <ContentTemplate> <!--
I have am using an asp:FormView control with elements such as: <asp:TextBox id=FirstName runat=server
In ASP.NET, I have a FormView which is bound to an ObjectDataSource. The FormView
I have an asp.net Formview connected to an SQL datasource. When I create/edit/delete a
I have a FormView control in an ASP.NET 2.0 app. I've got the database
I have an asp:FormView on a control (in an ascx file) which is loaded
I have an asp:FormView with an ItemTemplate. I'd like to design the content within
I have an asp:FormView control bound to a datasource. Everything is working fine. If
I have - for instance - an asp:FormView which supports Read, Insert, Update, Delete

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.