Hi,
In /Controller/Models/Transaction.cs, this code below could make drop-down list of Category breaks if you don't choose any category. I know we can set range in the Transaction Model, but it is still a choice to choose.
Is there any way to improve that from AddOrEdit.cshtml side? cuz I know you remain CategoryId=0 for new category However, you insert a new CategoryId=0 in the model which makes it become a choice to choose.
[NonAction]
public void PopulateCategories()
{
var CategoryCollection = _context.Categories.ToList();
Category DefaultCategory = new Category() { CategoryId = 0, Title = "Choose a Category" };
CategoryCollection.Insert(0, DefaultCategory);
ViewBag.Categories = CategoryCollection;
}
Origin display:

Expected display (default is CategoryId=1, and won't insert a CategoryId=0):

Thank you.
Hi,
In
/Controller/Models/Transaction.cs, this code below could make drop-down list of Category breaks if you don't choose any category. I know we can set range in the Transaction Model, but it is still a choice to choose.Is there any way to improve that from AddOrEdit.cshtml side? cuz I know you remain CategoryId=0 for
new categoryHowever, you insert a new CategoryId=0 in the model which makes it become a choice to choose.Origin display:

Expected display (default is CategoryId=1, and won't insert a CategoryId=0):

Thank you.