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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:47:00+00:00 2026-06-01T21:47:00+00:00

I want to edit the data of a specific field. The problem I got

  • 0

I want to edit the data of a specific field. The problem I got is that the field name is a string, for example.

In my view I have the parameter like this:

<div class="editable" id="cnso">@Model.cnso</div>

I get that field and call my controller via Ajax using jeditable:

$('.editable').editable('/Req/UpdateField', {
    tooltip: 'Click to edit...',
    submitdata : {
        nreqid : function() {
            return $("#nreqid").val();
        }
    }
});

My controller got the name of the field (cnso) in the string id. The problem is to update my model. Some code of my controller.

public string UpdateField(string id, string value, int nreqid)
{
    /*
     *        id - id of the field. This value can be used on the
     *             server side to determine what property of the
     *             company should be updated.
     *     value - text that is entered in the input field.
     *    nreqid - this is additional parameter that will
     *             be added to the request. Value of this parameter
     *             is a value of the hidden field with an id "ReqId".
     */
    ModelState.Clear();

    if (ModelState.IsValid)
    {
        //db.Entry(req).State = EntityState.Modified;
        //db.SaveChanges();
        Req req = db.Req.Find(nreqid);
        req."id" = "2";  // <--- Problem here !!!
    }
}

My model object, Req, has the field cnso, and my id string has the “cnso”, so how can I select the cnso from my string id?

  • 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-01T21:47:03+00:00Added an answer on June 1, 2026 at 9:47 pm

    Using reflection you could do:

    Type t = typeof(Req);
    PropertyInfo p = t.GetProperty(id);
    if(p != null)
        p.SetValue(req, "2", null);
    

    Alternatively, if there’s not too many properties, you could make a different Update action for all the properties you need. I don’t know the circumstances you need this for, but updating individual properties in a table one a time might not be the best design.

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

Sidebar

Related Questions

I have an input edit field where the user can enter data. I want
I have a UITableView that I want to edit inside of a UITableViewController. This
I have a page that generates json data from several fields and I want
I have data that I want to pull from a mySQL database and I
I am using sqlite in my app, i want to edit some data in
I want to copy my NSDictionary's data into plist and also edit some data
I want to display and edit some objects in a WPF data grid and
I have a MFMailComposeViewController wherein I want to edit the mail body, but I
Using the Authors/Books catalog example, let's say I want to edit the info for
I have a devXpress Gridview and there's a functionality to edit specific rows. I

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.