Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Category Drop Down List #1

Open
MarsWangyang opened this issue Sep 20, 2022 · 0 comments
Open

About Category Drop Down List #1

MarsWangyang opened this issue Sep 20, 2022 · 0 comments

Comments

@MarsWangyang
Copy link

MarsWangyang commented Sep 20, 2022

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:
image

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

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant