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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:21:51+00:00 2026-05-11T11:21:51+00:00

I have a strange problem. I am trying to update some fields using linq

  • 0

I have a strange problem. I am trying to update some fields using linq and it is not working. I tried to build the site and debug it which works and shows that the function is called. I also tried manually adding the values in the code behind file and that works too but somehow on runtime the form doesnt pass the values back from the text fields.

<%@ Page Language='C#' AutoEventWireup='true' CodeFile='AddEditBook1.aspx.cs' MasterPageFile='../AdminMaster.master' Inherits='AdminPanel_AddEditBook1' Title='Add or Edit Book Page'%>  <asp:Content ID='Content1' ContentPlaceHolderID='ContentPagePlaceHolder1' Runat='Server'> <div class='content'>      <div class='titleMain'>Library -> Add or Edit Book Page     </div>     <h1><span></span>Add or Edit Book Page</h1>      <div class='contentpage' >         <p>On this page you can Add or Edit Book Page</p>          <asp:Label ID='AddEditBookMsg' runat='server' Visible='false' />              <table width='650'  class='table' cellspacing='15'>                 <tr>                     <td>Book ID</td>                     <td><asp:Label ID='BookId' runat='server' /></td>                 </tr>                 <tr>                     <td>Book name</td>                     <td><asp:TextBox ID='BookName' runat='server' /></td>                 </tr>                 <tr>                     <td>Author</td>                     <td><asp:TextBox ID='BookAuthor' runat='server' Text='' /></td>                 </tr> 

Code:

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq;  public partial class AdminPanel_AddEditBook1 : System.Web.UI.Page {     // book represents 3 tables     protected void Page_Load(object sender, EventArgs e)     {         AddEditBookMsg.Visible = false;         if (Request['book_id'] != null)         {             GetExistingBook();         }     }      public void GetExistingBook()     {         BooksDataContext book = new BooksDataContext();         int book_id = Int32.Parse(Request['book_id'].ToString());         var bookexist = book.books.Single(b => b.book_id == book_id);         var bookDDL = from c in book.categories                       select c;         var bookexistdesc = book.bookdescs.Single(bds => bds.book_id == book_id);         if (bookexist.book_id == book_id)         {             BookName.Text = bookexist.book_name;             BookAuthor.Text = bookexist.book_author;             BookShortDesc.Text = bookexist.book_short_desc;             BookLongDesc.Text = bookexistdesc.book_long_desc;             BookImg.Text = bookexist.book_img;             BookSqu.Text = bookexist.book_squ;             BookArrived.Text = bookexist.book_arrived.ToString();             BookQty.Text = bookexist.book_qty.ToString();              if (!Page.IsPostBack)             {                 CaID.DataSource = bookDDL;                 CaID.DataTextField = 'ca_name';                 CaID.DataValueField = 'ca_id';                 CaID.DataBind();             }         }     }      protected void update_Click(object sender, EventArgs e)     {         BooksDataContext book = new BooksDataContext();          int book_id = Int32.Parse(Request['book_id'].ToString());         book bookexist2 = book.books.Single(b1 => b1.book_id == book_id);         bookdesc bookexistdesc2 = book.bookdescs.Single(bds1 => bds1.book_id == book_id);           bookexist2.book_name = BookName.Text;         bookexist2.book_author = BookAuthor.Text.ToString();         bookexist2.book_short_desc = BookShortDesc.Text;          bookexist2.book_img = BookImg.Text;         bookexist2.book_squ = BookSqu.Text;         bookexist2.book_arrived = DateTime.Parse(BookArrived.Text);         bookexist2.book_qty = Int32.Parse(BookQty.Text);          bookexistdesc2.book_long_desc = BookLongDesc.Text;         book.SubmitChanges();     } } 
  • 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. 2026-05-11T11:21:51+00:00Added an answer on May 11, 2026 at 11:21 am

    You forgot to check if it is a postback in Page_Load. You’ll reload from the db on postback too…

    if (!IsPostback()) {   if (Request['book_id'] != null)   {     GetExistingBook();   } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Npgsql is a .NET provider for PostgreSQL. Whether or not… May 11, 2026 at 11:33 pm
  • Editorial Team
    Editorial Team added an answer To answer my own question, after posting on openssl mailing… May 11, 2026 at 11:33 pm
  • Editorial Team
    Editorial Team added an answer Basically, clone is broken. Nothing will work with generics easily.… May 11, 2026 at 11:33 pm

Related Questions

I am seeing a very strange problem on one of my production boxes. We
I am using JPA with Hibernate underneath, and I am having trouble getting merge
I'm hoping someone has seen this before because I can't for the life of
I am seeing a strange problem: I have a linux machine, installed JDK1.6 on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.