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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:10:29+00:00 2026-06-13T01:10:29+00:00

I am trying to get the textchanged value from textbox to update in my

  • 0

I am trying to get the textchanged value from textbox to update in my Controller.
View

  @Html.TextBox("Quantity", item.Quantity)

  <a  href="@Url.Action("Update", "Shopping", new { id = Request.QueryString["UserID"], productid = item.ProductID, qty ="Quantity", unitrate = item.Rate })">     
<img alt="updateitem" style="vertical-align: middle;" height="17px" src="~/Images/product_updates_image.png"
 title="update" id="imgUpdate" />
</a>

And in My Controller with Update

 public ActionResult Update(string id, string productid, int qty, decimal unitrate)
        {
            if (ModelState.IsValid)
            {
                int _records = UpdatePrice(id,productid,qty,unitrate);
                if (_records > 0)
                {
                    return RedirectToAction("Index1", "Shopping");
                }
                else
                {
                    ModelState.AddModelError("","Can Not Update");
                }
            }
            return View("Index1");
        }

Update Function

public int UpdatePrice(string id,string productid, int qty, decimal unitrate)
    {
        con.Open();        
        var total = qty * unitrate;
        SqlCommand cmd = new SqlCommand("Update [Cpecial_Shopping_Cart_tbl] Set Price='"+ total +"' where [User ID]='" + id + "' and [Product ID]='" + productid + "'", con);
        cmd.Parameters.AddWithValue("@total", total);
        return cmd.ExecuteNonQuery();
    }

I passed the Textbox name for the quantity variable in @Html.ActionLink. But when the text box value is changed, value is not passed in it.

EDIT :

Initially the value for the textbox from DB is 1. When I change the textbox value, its not getting updated and the same value is updated even when the form is posted.

  • 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-13T01:10:30+00:00Added an answer on June 13, 2026 at 1:10 am

    You need to use a form to send (POST) values from a View into a controller.

    This is a rough example:

    @using (Html.BeginForm("Update", "Shopping", FormMethod.Post, new { @id = "myHtmlForm" }))
    {
        @Html.Hidden("id", Request.QueryString["UserID"]);
        @Html.Hidden("productid", item.ProductID)
        @Html.Hidden("unitrate", item.Rate)
    
        @Html.TextBox("qty", item.Quantity)
    
        <a href="javascript:document.getElementById('myHtmlForm').submit();">
            <img alt="updateitem" style="vertical-align: middle;" height="17px" src="~/Images/product_updates_image.png"
                title="update" id="imgUpdate" />
        </a>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get a value from a object isn't working out. class Asset <
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
I'm trying get some licensing code from AndroidPit.com working, but I get Unable to
I am trying get the html within .event_recur. $(.entry).each(function(){ alert($(this).find(.event_recur).html()); }); <div class=entry> <p
When I'm trying get method from remote webservice it gives me error. My code
I'm trying get bytes from bitmap in blackberry using the next method in Bitmap:
I am trying to get such effect: When I click textbox,the caret moves to
I am trying to get an textBox to fire it's onTextChanged event every time

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.