Send data to a View and display it





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















My issue is the following:



I can not send my data for display in my view.



First, you must know that I connect to an external Filemaker DB and that the "results" variable retrieves this data.



"results" is of type IEnumerable .



For the recovery part, results contains my model that he found.



But it seems that I'm missing a piece of code because my view does not show any data.



Indeed, my goal is to send existing data into a form.



Could you help me?



Controller



   [Authorize]
public ActionResult Index()
{
//HttpContext.Session.SetInt32("idMember", 26);

List<Models.Members> list = new List<Models.Members>();
Models.Members m = new Models.Members();
m.Member_NameFirst = "test1";
Models.Members m2 = new Models.Members();
m2.Member_NameFirst = "test2";
list.Add(m);
list.Add(m2);
IEnumerable<Models.Members> members = list;
return View(list);
}


View



@model IEnumerable<Members>


@foreach (var item in Model)
{
@Html.DisplayFor(o => item.Member_NameFirst)
}









share|improve this question

























  • If results" is of type IEnumerable, why is your view not strongly typed to a collection type ? Are you getting an error now ( about the passed data type not matching than what the view is expecting) ? What is happening now ?

    – Shyju
    Nov 23 '18 at 16:33













  • I only receive this error: jquery.js:9600 GET localhost:44338/Members/GetMember 500

    – Korpin
    Nov 23 '18 at 16:39











  • That means your GetMember method is crashing. Check the response tab of the ajax call to see the details/ put a breakpoint in your method and see which line is crashing.

    – Shyju
    Nov 23 '18 at 16:41











  • it crashes when he hit : xhr.send( options.hasContent && options.data || null ); Dont know how to solve it :/

    – Korpin
    Nov 23 '18 at 16:57











  • Ofc you are right! So i guess i need to declare to my view: @model List<jak.formulaire.Models.Members> ?

    – Korpin
    Nov 23 '18 at 17:28


















0















My issue is the following:



I can not send my data for display in my view.



First, you must know that I connect to an external Filemaker DB and that the "results" variable retrieves this data.



"results" is of type IEnumerable .



For the recovery part, results contains my model that he found.



But it seems that I'm missing a piece of code because my view does not show any data.



Indeed, my goal is to send existing data into a form.



Could you help me?



Controller



   [Authorize]
public ActionResult Index()
{
//HttpContext.Session.SetInt32("idMember", 26);

List<Models.Members> list = new List<Models.Members>();
Models.Members m = new Models.Members();
m.Member_NameFirst = "test1";
Models.Members m2 = new Models.Members();
m2.Member_NameFirst = "test2";
list.Add(m);
list.Add(m2);
IEnumerable<Models.Members> members = list;
return View(list);
}


View



@model IEnumerable<Members>


@foreach (var item in Model)
{
@Html.DisplayFor(o => item.Member_NameFirst)
}









share|improve this question

























  • If results" is of type IEnumerable, why is your view not strongly typed to a collection type ? Are you getting an error now ( about the passed data type not matching than what the view is expecting) ? What is happening now ?

    – Shyju
    Nov 23 '18 at 16:33













  • I only receive this error: jquery.js:9600 GET localhost:44338/Members/GetMember 500

    – Korpin
    Nov 23 '18 at 16:39











  • That means your GetMember method is crashing. Check the response tab of the ajax call to see the details/ put a breakpoint in your method and see which line is crashing.

    – Shyju
    Nov 23 '18 at 16:41











  • it crashes when he hit : xhr.send( options.hasContent && options.data || null ); Dont know how to solve it :/

    – Korpin
    Nov 23 '18 at 16:57











  • Ofc you are right! So i guess i need to declare to my view: @model List<jak.formulaire.Models.Members> ?

    – Korpin
    Nov 23 '18 at 17:28














0












0








0








My issue is the following:



I can not send my data for display in my view.



First, you must know that I connect to an external Filemaker DB and that the "results" variable retrieves this data.



"results" is of type IEnumerable .



For the recovery part, results contains my model that he found.



But it seems that I'm missing a piece of code because my view does not show any data.



Indeed, my goal is to send existing data into a form.



Could you help me?



Controller



   [Authorize]
public ActionResult Index()
{
//HttpContext.Session.SetInt32("idMember", 26);

List<Models.Members> list = new List<Models.Members>();
Models.Members m = new Models.Members();
m.Member_NameFirst = "test1";
Models.Members m2 = new Models.Members();
m2.Member_NameFirst = "test2";
list.Add(m);
list.Add(m2);
IEnumerable<Models.Members> members = list;
return View(list);
}


View



@model IEnumerable<Members>


@foreach (var item in Model)
{
@Html.DisplayFor(o => item.Member_NameFirst)
}









share|improve this question
















My issue is the following:



I can not send my data for display in my view.



First, you must know that I connect to an external Filemaker DB and that the "results" variable retrieves this data.



"results" is of type IEnumerable .



For the recovery part, results contains my model that he found.



But it seems that I'm missing a piece of code because my view does not show any data.



Indeed, my goal is to send existing data into a form.



Could you help me?



Controller



   [Authorize]
public ActionResult Index()
{
//HttpContext.Session.SetInt32("idMember", 26);

List<Models.Members> list = new List<Models.Members>();
Models.Members m = new Models.Members();
m.Member_NameFirst = "test1";
Models.Members m2 = new Models.Members();
m2.Member_NameFirst = "test2";
list.Add(m);
list.Add(m2);
IEnumerable<Models.Members> members = list;
return View(list);
}


View



@model IEnumerable<Members>


@foreach (var item in Model)
{
@Html.DisplayFor(o => item.Member_NameFirst)
}






asp.net ajax asp.net-mvc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 7:36







user3559349

















asked Nov 23 '18 at 16:31









KorpinKorpin

7810




7810













  • If results" is of type IEnumerable, why is your view not strongly typed to a collection type ? Are you getting an error now ( about the passed data type not matching than what the view is expecting) ? What is happening now ?

    – Shyju
    Nov 23 '18 at 16:33













  • I only receive this error: jquery.js:9600 GET localhost:44338/Members/GetMember 500

    – Korpin
    Nov 23 '18 at 16:39











  • That means your GetMember method is crashing. Check the response tab of the ajax call to see the details/ put a breakpoint in your method and see which line is crashing.

    – Shyju
    Nov 23 '18 at 16:41











  • it crashes when he hit : xhr.send( options.hasContent && options.data || null ); Dont know how to solve it :/

    – Korpin
    Nov 23 '18 at 16:57











  • Ofc you are right! So i guess i need to declare to my view: @model List<jak.formulaire.Models.Members> ?

    – Korpin
    Nov 23 '18 at 17:28



















  • If results" is of type IEnumerable, why is your view not strongly typed to a collection type ? Are you getting an error now ( about the passed data type not matching than what the view is expecting) ? What is happening now ?

    – Shyju
    Nov 23 '18 at 16:33













  • I only receive this error: jquery.js:9600 GET localhost:44338/Members/GetMember 500

    – Korpin
    Nov 23 '18 at 16:39











  • That means your GetMember method is crashing. Check the response tab of the ajax call to see the details/ put a breakpoint in your method and see which line is crashing.

    – Shyju
    Nov 23 '18 at 16:41











  • it crashes when he hit : xhr.send( options.hasContent && options.data || null ); Dont know how to solve it :/

    – Korpin
    Nov 23 '18 at 16:57











  • Ofc you are right! So i guess i need to declare to my view: @model List<jak.formulaire.Models.Members> ?

    – Korpin
    Nov 23 '18 at 17:28

















If results" is of type IEnumerable, why is your view not strongly typed to a collection type ? Are you getting an error now ( about the passed data type not matching than what the view is expecting) ? What is happening now ?

– Shyju
Nov 23 '18 at 16:33







If results" is of type IEnumerable, why is your view not strongly typed to a collection type ? Are you getting an error now ( about the passed data type not matching than what the view is expecting) ? What is happening now ?

– Shyju
Nov 23 '18 at 16:33















I only receive this error: jquery.js:9600 GET localhost:44338/Members/GetMember 500

– Korpin
Nov 23 '18 at 16:39





I only receive this error: jquery.js:9600 GET localhost:44338/Members/GetMember 500

– Korpin
Nov 23 '18 at 16:39













That means your GetMember method is crashing. Check the response tab of the ajax call to see the details/ put a breakpoint in your method and see which line is crashing.

– Shyju
Nov 23 '18 at 16:41





That means your GetMember method is crashing. Check the response tab of the ajax call to see the details/ put a breakpoint in your method and see which line is crashing.

– Shyju
Nov 23 '18 at 16:41













it crashes when he hit : xhr.send( options.hasContent && options.data || null ); Dont know how to solve it :/

– Korpin
Nov 23 '18 at 16:57





it crashes when he hit : xhr.send( options.hasContent && options.data || null ); Dont know how to solve it :/

– Korpin
Nov 23 '18 at 16:57













Ofc you are right! So i guess i need to declare to my view: @model List<jak.formulaire.Models.Members> ?

– Korpin
Nov 23 '18 at 17:28





Ofc you are right! So i guess i need to declare to my view: @model List<jak.formulaire.Models.Members> ?

– Korpin
Nov 23 '18 at 17:28












1 Answer
1






active

oldest

votes


















2














Something like this for your result:



@model IEnumerable<BlockedIPViewModel>


Ref. How to pass IEnumerable list to controller in MVC including checkbox state?



This is my successful example.



Class:



namespace Test.Models
{
public class Members
{
public string Member_NameFirst { get; set; }
}
}


Controller:



public ActionResult Index()
{
// Test data
List<Members> list = new List<Members>();
Members m = new Members();
m.Member_NameFirst = "test1";
Members m2 = new Members();
m2.Member_NameFirst = "test2";
list.Add(m);
list.Add(m2);
IEnumerable<Members> members = list;
return View(list);
}


[Index] View:



@model IEnumerable<Test.Models.Members>

@foreach (var item in Model)
{
@Html.DisplayFor(o => item.Member_NameFirst)
}


Be careful of your view @model as well.






share|improve this answer


























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Nov 25 '18 at 3:52












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450179%2fsend-data-to-a-view-and-display-it%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Something like this for your result:



@model IEnumerable<BlockedIPViewModel>


Ref. How to pass IEnumerable list to controller in MVC including checkbox state?



This is my successful example.



Class:



namespace Test.Models
{
public class Members
{
public string Member_NameFirst { get; set; }
}
}


Controller:



public ActionResult Index()
{
// Test data
List<Members> list = new List<Members>();
Members m = new Members();
m.Member_NameFirst = "test1";
Members m2 = new Members();
m2.Member_NameFirst = "test2";
list.Add(m);
list.Add(m2);
IEnumerable<Members> members = list;
return View(list);
}


[Index] View:



@model IEnumerable<Test.Models.Members>

@foreach (var item in Model)
{
@Html.DisplayFor(o => item.Member_NameFirst)
}


Be careful of your view @model as well.






share|improve this answer


























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Nov 25 '18 at 3:52
















2














Something like this for your result:



@model IEnumerable<BlockedIPViewModel>


Ref. How to pass IEnumerable list to controller in MVC including checkbox state?



This is my successful example.



Class:



namespace Test.Models
{
public class Members
{
public string Member_NameFirst { get; set; }
}
}


Controller:



public ActionResult Index()
{
// Test data
List<Members> list = new List<Members>();
Members m = new Members();
m.Member_NameFirst = "test1";
Members m2 = new Members();
m2.Member_NameFirst = "test2";
list.Add(m);
list.Add(m2);
IEnumerable<Members> members = list;
return View(list);
}


[Index] View:



@model IEnumerable<Test.Models.Members>

@foreach (var item in Model)
{
@Html.DisplayFor(o => item.Member_NameFirst)
}


Be careful of your view @model as well.






share|improve this answer


























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Nov 25 '18 at 3:52














2












2








2







Something like this for your result:



@model IEnumerable<BlockedIPViewModel>


Ref. How to pass IEnumerable list to controller in MVC including checkbox state?



This is my successful example.



Class:



namespace Test.Models
{
public class Members
{
public string Member_NameFirst { get; set; }
}
}


Controller:



public ActionResult Index()
{
// Test data
List<Members> list = new List<Members>();
Members m = new Members();
m.Member_NameFirst = "test1";
Members m2 = new Members();
m2.Member_NameFirst = "test2";
list.Add(m);
list.Add(m2);
IEnumerable<Members> members = list;
return View(list);
}


[Index] View:



@model IEnumerable<Test.Models.Members>

@foreach (var item in Model)
{
@Html.DisplayFor(o => item.Member_NameFirst)
}


Be careful of your view @model as well.






share|improve this answer















Something like this for your result:



@model IEnumerable<BlockedIPViewModel>


Ref. How to pass IEnumerable list to controller in MVC including checkbox state?



This is my successful example.



Class:



namespace Test.Models
{
public class Members
{
public string Member_NameFirst { get; set; }
}
}


Controller:



public ActionResult Index()
{
// Test data
List<Members> list = new List<Members>();
Members m = new Members();
m.Member_NameFirst = "test1";
Members m2 = new Members();
m2.Member_NameFirst = "test2";
list.Add(m);
list.Add(m2);
IEnumerable<Members> members = list;
return View(list);
}


[Index] View:



@model IEnumerable<Test.Models.Members>

@foreach (var item in Model)
{
@Html.DisplayFor(o => item.Member_NameFirst)
}


Be careful of your view @model as well.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 22:36

























answered Nov 23 '18 at 18:23









Wing Kui TsoiWing Kui Tsoi

154313




154313













  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Nov 25 '18 at 3:52



















  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Nov 25 '18 at 3:52

















Comments are not for extended discussion; this conversation has been moved to chat.

– Samuel Liew
Nov 25 '18 at 3:52





Comments are not for extended discussion; this conversation has been moved to chat.

– Samuel Liew
Nov 25 '18 at 3:52




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450179%2fsend-data-to-a-view-and-display-it%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy