user793468
user793468

Reputation: 4976

Returning a value from Database

What do I need in order to return a value after inserting data in Database?

here is my code for the controller action:

        [HttpPost]
    public ActionResult InsertData(int? key)
    {
        var TestData = new Data();
        DataContext.InsertData(TestData);

        return Content(TestData.Key);
    }

Here is the error I get:

The best overloaded method match for 'System.Web.Mvc.Controller.Content(string)' has some invalid arguments

Upvotes: 1

Views: 52

Answers (1)

Coding Flow
Coding Flow

Reputation: 21881

It is telling you you are passing the wrong data type in it needs to be a string

Try:

[HttpPost]
    public ActionResult InsertData(int? key)
    {
        var TestData = new Data();
        DataContext.InsertData(TestData);

        return Content(TestData.Key.ToString());
    }

Upvotes: 3

Related Questions