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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:39:09+00:00 2026-06-12T00:39:09+00:00

I am having trouble approaching a solution to my current situation: I need to

  • 0

I am having trouble approaching a solution to my current situation:

I need to assign a dynamic value to a C# variable since C# is what queries my database.

This value will have to match the Primary Key ID for their selected (clicked upon, etc.) sql queried entry.

I never know how many entries (or which ones) there will be based on their search.

So far, they put their search conditions into a form, the database is dynamically queried, and the results are displayed in order row after row.

Now, I need a button (or some kind of user selected interface) that can tell me which entry they choose to edit, and then take the values of that entry in the database to the View & Edit page.

I can do all of this except, how can I tell which entry they click on (or otherwise choose) when C# is already done rendering the page by the time the user can give any input? JavaScript can’t query a database, so how is this possible? Keep in mind, I know jQuery, but don’t know any AJAX.

I am using WebMatrix C# razor, html, css, JavaScript, SQL Server Compact, and jQuery (standard WebMatrix setup, I’m sure).

Any help is much appreciated.

  • 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-12T00:39:10+00:00Added an answer on June 12, 2026 at 12:39 am

    Ok, as GmG had commented, the webGrid is designed to help with this issue, however, if you prefer not to use that answer and construct your own, here is what I found that worked perfectly for me (even better for my specific case):

    Within the @foreach(var row in db.Query(“queryString”)) loop, I (among the summarized information) added a form so that each entry found, would have its own form. In the form I placed only a submit button and a hidden input text element with any given specified name set in the “name” attribute (i.e., name=”inputName”). The value of this hidden element was @row.EntryID (i.e., value=”@row.EntryID”), which would plot the value of this field with the unique primary key of the entry found in the database. With the form action set to another file (i.e., action=”/somefile.cshtml”) in that page, I simply extracted the EntryID from the hidden input text field (i.e., var someVariable = Request.Form[“inputName”];). Since the request would only grab from whichever form submitted it and the value of the hidden input field was dynamically plotted, I can always get the ID of the entry they clicked the button for.

    I hope this helps anyone who wants to perform a similar function without using the WebGrid helper (although, you probably want to, I mean that is what its there for). As for some like me, however, we may know how to better control it this way (because we may not know jack about helpers and how to tweak the little minute configurations therein required to display, style, and control the web interface just the way we want to).

    Anyway, again, hope this helps someone.

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

Sidebar

Related Questions

Having trouble finding a solution for my situation here. Sorry if this has been
Having trouble wrapping a BOOL value in NSValue. I tried this: [NSValue valueWithPointer:[NSNumber numberWithBool:YES]]
Having trouble setting the value of a declared variable in MySQL. If I run
Having trouble framing this assertion in Rspec for my rails app. A User has
Having trouble getting this syntax right: SELECT DISTINCT id FROM metadata WHERE (meta_key =
Having trouble with this -- a couple of other related posts out there, but
Having trouble getting JQuery to access the parent form field 'inputStart's value when a
Having trouble with an sql statement to retrieve a record between two timestamps. This
Having trouble with iterator. It need to iterate over ArrayList and find any other
I'm having some trouble approaching a +1/-1 voting system in PHP, it should vaguely

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.