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
Guest User
Tech Writer
64
2.7k
Show items from SelectList with condition
May 7 2021 8:23 AM
I want to show in the List only the items where "DataSfarsit" < Datetime.Now.
How can I do that?
controller:
[Authorize]
public
ActionResult Create()
{
ViewBag.IDLicitatie =
new
SelectList(db.Licitatie,
"IDLicitatie"
,
"IDLicitatie"
).Where(...);
ViewBag.IdUser = db.Useri.FirstOrDefault(x => x.Email == User.Identity.Name).IdUser;
return
View();
}
The model:
public
partial
class
Licitatie
{
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Usage"
,
"CA2214:DoNotCallOverridableMethodsInConstructors"
)]
public
Licitatie()
{
this
.Oferte =
new
HashSet<Oferte>();
}
public
int
IDLicitatie {
get
;
set
; }
public
System.DateTime DataPornire {
get
;
set
; }
public
System.DateTime DataIncheiere {
get
;
set
; }
public
decimal
PretInitial {
get
;
set
; }
public
int
IDProdus {
get
;
set
; }
public
virtual
Produse Produse {
get
;
set
; }
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Usage"
,
"CA2227:CollectionPropertiesShouldBeReadOnly"
)]
public
virtual
ICollection<Oferte> Oferte {
get
;
set
; }
So basically I want the IDLicitate = "4" from there to not appear because it has DataSfarsit < Datetime.now.
Reply
Answers (
1
)
asp.net core jquery to re-enable ddl ignore ddl source
asp.net core build a matrix 5x5 and apply style