Click here to Skip to main content
15,881,757 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Application for creating vector objects Pin
Pete O'Hanlon2-Mar-20 2:59
mvePete O'Hanlon2-Mar-20 2:59 
GeneralRe: Application for creating vector objects Pin
MitchCZ2-Mar-20 3:31
MitchCZ2-Mar-20 3:31 
GeneralRe: Application for creating vector objects Pin
Pete O'Hanlon2-Mar-20 4:20
mvePete O'Hanlon2-Mar-20 4:20 
QuestionSome GridView controls are running empty rows. Any ideas to fix Pin
samflex25-Feb-20 7:57
samflex25-Feb-20 7:57 
SuggestionRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Richard MacCutchan25-Feb-20 8:51
mveRichard MacCutchan25-Feb-20 8:51 
GeneralRe: Some GridView controls are running empty rows. Any ideas to fix Pin
samflex25-Feb-20 9:03
samflex25-Feb-20 9:03 
GeneralRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Richard MacCutchan25-Feb-20 9:26
mveRichard MacCutchan25-Feb-20 9:26 
AnswerRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Mycroft Holmes25-Feb-20 11:35
professionalMycroft Holmes25-Feb-20 11:35 
GeneralRe: Some GridView controls are running empty rows. Any ideas to fix Pin
samflex25-Feb-20 17:20
samflex25-Feb-20 17:20 
SuggestionRe: Some GridView controls are running empty rows. Any ideas to fix Pin
phil.o25-Feb-20 20:19
professionalphil.o25-Feb-20 20:19 
GeneralRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Richard MacCutchan25-Feb-20 21:22
mveRichard MacCutchan25-Feb-20 21:22 
AnswerRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Blikkies26-Feb-20 1:19
professionalBlikkies26-Feb-20 1:19 
QuestionASP.NET + Multi Form using Textbox problem Pin
kerek224-Feb-20 21:41
kerek224-Feb-20 21:41 
SuggestionRe: ASP.NET + Multi Form using Textbox problem Pin
Richard MacCutchan24-Feb-20 23:16
mveRichard MacCutchan24-Feb-20 23:16 
QuestionWhen string in a cell has double quotes those appear in Excel after export. How do I remove them? Pin
Member 1140330424-Feb-20 10:19
Member 1140330424-Feb-20 10:19 
AnswerRe: When string in a cell has double quotes those appear in Excel after export. How do I remove them? Pin
Member 1140330424-Feb-20 11:26
Member 1140330424-Feb-20 11:26 
Rant[REPOST] When string in a cell has double quotes those appear in Excel after export. How do I remove them? Pin
Richard Deeming25-Feb-20 2:27
mveRichard Deeming25-Feb-20 2:27 
Questionreturning null value from populated selectlist with DB data Pin
ElenaRez21-Feb-20 21:11
ElenaRez21-Feb-20 21:11 
I'm implementing asp.net core MVC project. In my controller class called ApiApplicant, Create method, I have 3 selectlists that its items should be populated from a table called APIApplicantHistory. My models and create method and view are implemented like following:


using System.Collections.Generic;

namespace CSDDashboard.Models
{
public partial class Apiapplicant
{
public Apiapplicant()
{
ApiApplicantHistory = new HashSet<apiapplicanthistory>();
}

public int Id { get; set; }
public string ApiRequestDate { get; set; }
public int? ApiRequestNo { get; set; }
public int? Apiid { get; set; }
public int? ApplicantId { get; set; }
public int? GateId { get; set; }
public string NocRequestDate { get; set; }
public string NocRequestNo { get; set; }
public string Url { get; set; }
public string Description { get; set; }
public bool? IsDeleted { get; set; }

public virtual Api Api { get; set; }
public virtual Applicant Applicant { get; set; }
public virtual Gate Gate { get; set; }
public virtual ICollection<apiapplicanthistory> ApiApplicantHistory { get; set; }
}
}

using System;
using System.Collections.Generic;

namespace CSDDashboard.Models
{
public partial class ApiApplicantHistory
{
public int Id { get; set; }
public int? ApiApplicantId { get; set; }
public string Date { get; set; }
public int? SentResponseType { get; set; }
public int? UnconfirmedReason { get; set; }
public int LastReqStatus { get; set; }
public string Description { get; set; }

public virtual Apiapplicant ApiApplicant { get; set; }
public virtual EntityType LastReqStatusNavigation { get; set; }
public virtual EntityType SentResponseTypeNavigation { get; set; }
public virtual EntityType UnconfirmedReasonNavigation { get; set; }
}
}


using System;
using System.Collections.Generic;

namespace CSDDashboard.Models
{
public partial class EntityType
{
public EntityType()
{
ApiApplicantHistoryLastReqStatusNavigation = new HashSet<apiapplicanthistory>();
ApiApplicantHistorySentResponseTypeNavigation = new HashSet<apiapplicanthistory>();
ApiApplicantHistoryUnconfirmedReasonNavigation = new HashSet<apiapplicanthistory>();
}

public int Id { get; set; }
public string Name { get; set; }
public string EntityKey { get; set; }

public virtual ICollection<apiapplicanthistory> ApiApplicantHistoryLastReqStatusNavigation { get; set; }
public virtual ICollection<apiapplicanthistory> ApiApplicantHistorySentResponseTypeNavigation { get; set; }
public virtual ICollection<apiapplicanthistory> ApiApplicantHistoryUnconfirmedReasonNavigation { get; set; }

}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CSDDashboard.Models
{
public class APIApplicantViewModel
{
public Apiapplicant apiApplicantvm { get; set; }

public ApiApplicantHistory apiApplicantHistoryvm { get; set; }
}
}


public class ApiapplicantsController : Controller
{
private readonly CSSDDashboardContext _context;

public ApiapplicantsController(CSSDDashboardContext context)
{
_context = context;
}

public IActionResult Create()
{

ViewData["sentResponseType"] = new SelectList(_context.EntityType.Where(g => g.EntityKey == "sentResponseType")
        .Include(x => x.ApiApplicantHistoryLastReqStatusNavigation).ToList(), "ID", "name");

ViewData["unconfirmedReason"] = new SelectList(_context.EntityType.Where(g => g.EntityKey == "unconfirmedReason").ToList(), "ID", "name");
ViewData["lastReqStatus"] = new SelectList(_context.EntityType.Where(g => g.EntityKey == "lastRequestStatus").ToList(), "ID", "name");

return View();

}
}

And a part of create view implementation:



@modelCSDDashboard.Models.APIApplicantViewModel

@{
ViewData["Title"] = "create";
}






























@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

In create method, all the viewData are filled with the correct related data but the problem is existing in Create view, after running the project an error like below is shown in Create page:

An unhandled exception occurred while processing the request.
NullReferenceException: Object reference not set to an instance of an object.

After debugging the code I understand that In create view, apiApplicantvm is not null but
ViewBag.sentResponseType
returns null and the above error is because of that. I appreciate if anyone could tells me how to fix the problem.
QuestionASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol18-Feb-20 8:32
Mou_kol18-Feb-20 8:32 
AnswerRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
jkirkerx19-Feb-20 9:15
professionaljkirkerx19-Feb-20 9:15 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol19-Feb-20 9:41
Mou_kol19-Feb-20 9:41 
AnswerRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
F-ES Sitecore19-Feb-20 23:01
professionalF-ES Sitecore19-Feb-20 23:01 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol21-Feb-20 22:36
Mou_kol21-Feb-20 22:36 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
F-ES Sitecore23-Feb-20 22:46
professionalF-ES Sitecore23-Feb-20 22:46 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
F-ES Sitecore23-Feb-20 22:52
professionalF-ES Sitecore23-Feb-20 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.