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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:35:19+00:00 2026-06-13T14:35:19+00:00

I passed my querystring in _Layout.cshtml page <li>@Html.ActionLink(Shopping, Index1, new { controller = Shopping,

  • 0

I passed my querystring in _Layout.cshtml page

  <li>@Html.ActionLink("Shopping", "Index1", new { controller = "Shopping", UserID = "Admin1" })</li>  

I have an update view to update the values from textbox

 @using (Html.BeginForm("Update", "Shopping", new { id = Request.QueryString["UserID"] }, FormMethod.Post, new { id = "myForm" }))
         {
               @Html.Hidden("id", @Request.QueryString["UserID"] as string)
               @Html.Hidden("productid", item.ProductID as string)
               @Html.TextBox("qty", item.Quantity)
               @Html.Hidden("unitrate", item.Rate)
               <input type="submit" value="Update" />
         }

In the first time post , i get the url like this

http://localhost:61110/Shopping/Index1?UserID=Admin1

But for the second time, after post i get the url like this

http://localhost:61110/Shopping/Index1

How to get the querystring value at all times when it the form is posted.

I also tried this mvc3: html.beginform search returning empty querystring

But couldnt get the querystring on second time post
Any suggestions.

EDIT : Update Action Code

[HttpPost]
        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",new { id = Request.QueryString["UserID"] });
                }
                else
                {
                    ModelState.AddModelError("","Can Not Update");
                }
            }
            return View("Index1");
        }

public int UpdatePrice(string id,string productid,int qty,decimal unitrate)
    {
        con.Open(); 
        var total = qty * unitrate;
        SqlCommand cmd = new SqlCommand("Update [Table_name] Set Quantity='" + qty + "',Price='" + total + "' where [User ID]='" + id + "' and [Product ID]='" + productid + "'", con);
        cmd.Parameters.AddWithValue("@total", total);
        return cmd.ExecuteNonQuery();
    }
  • 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-13T14:35:21+00:00Added an answer on June 13, 2026 at 2:35 pm

    You need to add the new { id = Request.QueryString["UserID"] } to the RedirectToAction in Update as well.

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

Sidebar

Related Questions

I passed a querystring value in _Layout.cshtml page <li>@Html.ActionLink(Contact, Contact, Home)</li> <li>@Html.ActionLink(Shopping, Index1, new
On every page of my website a token is passed in as a querystring
I have passed a value through a url to a C# .net page using
I am being passed a set of querystring parameters within a Parameters class with
Summary: I have passed the name of the id select tag into an Array.
I have a large querystring like http://terra.cic.local/web/index.cfm//pm/uebersicht?sucheAufgeklappt=was%2Cwie%2Cwohin%2Cwann%2Cwer&sucheVon=&sucheBis=&sucheIstErsteSeiteAnzahlProdukteErmitteln=false&sucheIDReiseart=26&sucheHotelart=1081&sucheHotelart=1082&sucheIDLand=347&sucheRegion=214&sucheIstZeitlichFlexibel=true&sucheDauer=&sucheAnzahlErwachsene=2&sucheAnzahlKinder=0&sucheAnzahlPersonen=2&sucheAnzahlSchlafzimmer=&sucheEntfernungStrand=&sucheEntfernungSkilift= this link will be pasted displayed in
I have an aspx web page (opener) which opens a popup window In the
I'm building a prototype search application using CakePHP and I have a search controller
I use code Request.QueryString[u] to read passed URL to my web application. Everything works
I have a resource handler that is Response.WriteFile(fileName) based on a parameter passed through

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.