TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Marius Vasile
552
1.9k
145.8k
asp.net core on filter empty fields are displayed
Mar 15 2021 3:41 PM
I have filter implemented for WOStatus. When app run, it will display an emty field. Details below
[BindProperty(SupportsGet =
true
)]
public
string SearchWOStatus { get; set; }
public
async Task<IActionResult> OnGetAsync()
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var orgid = await _context.UsersData.Where(s => s.Id == userId).Select(s => s.OrgID).FirstOrDefaultAsync();
WOVL = await(from a in _context.WOMains.Where(s => s.OrgID == orgid)
join b in _context.WOInitiators on a.WOMainID equals b.WOMainID into Temp1
from c in Temp1.DefaultIfEmpty()
join d in _context.WOPlanners on a.WOMainID equals d.WOMainID into Temp2
from e in Temp2.DefaultIfEmpty()
select
new
WOViewIndex
{
WOMainID = a.WOMainID,
WONumber = a.WONumber,
WONumberS = e == null ? 0 : e.WONumberS,
CreateDate = a.CreateDate,
Deficiency = c.Deficiency,
Activity = e == null ?
"--NONE--"
: e.Activity,
WOStatus = e == null ?
"--NONE--"
: e.WOStatus
}).ToListAsync();
return
Page();
}
public
async Task<IActionResult> OnPost(string SearchWOStatus)
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var orgid = await _context.UsersData.Where(s => s.Id == userId).Select(s => s.OrgID).FirstOrDefaultAsync();
if
(SearchWOStatus != null)
{
WOVL = await (from a in _context.WOMains.Where(s => s.OrgID == orgid)
join b in _context.WOInitiators on a.WOMainID equals b.WOMainID into Temp1
from c in Temp1.DefaultIfEmpty()
join d in _context.WOPlanners.Where(s => s.WOStatus.Equals(SearchWOStatus)) on a.WOMainID equals d.WOMainID into Temp2
from e in Temp2.DefaultIfEmpty()
select
new
WOViewIndex
{
WOMainID = a.WOMainID,
WONumber = a.WONumber,
WONumberS = e == null ? 0 : e.WONumberS,
CreateDate = a.CreateDate,
Deficiency = c.Deficiency,
Activity = e == null ?
"--NONE--"
: e.Activity,
WOStatus = e.WOStatus
}).ToListAsync();
}
return
Page();
}
<form method=
"post"
>
<div
class
=
"row no-gutters"
>
<div
class
=
"col-md-2 ml-2"
>
<label
class
=
"form-control text-white"
style=
"background-color:firebrick"
>Sort by WO Status</label>
</div>
<div
class
=
"col-md-2"
>
<select id=
"woStatus"
class
=
"form-control"
style=
"border-color:firebrick; color:firebrick"
OnChange=
"assignData()"
>
<option value=
""
>--Select WO Status--</option>
<option value=
"1"
>Initiated</option>
<option value=
"2"
>Reviewed</option>
<option value=
"3"
>Planned</option>
<option value=
"4"
>Approved</option>
<option value=
"5"
>Rejected</option>
<option value=
"6"
>Scheduled</option>
<option value=
"7"
>InProgress</option>
<option value=
"8"
>Completed</option>
<option value=
"9"
>Closed</option>
</select>
<input hidden asp-
for
=
"SearchWOStatus"
id=
"WOStatusName"
/>
</div>
<div
class
=
"col-md-1 ml-1"
>
<input
class
=
"btn btn-link"
style=
"border-color:firebrick; color:firebrick; width:150px"
type=
"submit"
value=
"Filter by Status"
/>
</div>
<div
class
=
"col-md-1 ml-1"
>
<a asp-route-page=
"/WO/Index"
class
=
"btn btn-link"
style=
"border-color:firebrick; color:firebrick; width:150px"
>Show All</a>
</div>
</div>
</form>
snap picture with view
Reply
Answers (
6
)
OCR with ASP.NET Framework v4.8
Windows CE in visual studio 2008