(#54) Dropdown in asp.net core with text and value property | Asp.Net Core tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we will learn how can we add text and value to a drop-down by using the option tag let's start let's create a drop round by using text and value let's go back to the visual studio and over here if you can notice that if you are using only the text value we are using this text for two purpose first one is we are displaying same text to the user and we are adding the same data to the database now in this video we will learn how can we modify this approach and we will display something different to a user and we will save some different data into the database what does it mean suppose over here in the stroke town I want to update this text property like one of the best language and for the English suppose I want to add some other text like global language and to the dutch suppose i want to add some more masses my custom message suppose i want to display this type of data to my user but into the database i want to save only in the english and dutch language i do not want to say this rest data to work with this type of situation we have to use value over here whatever you will write into the value that will be saved to your database so suppose in the value i am writing in the let's add value for these two language as well now we have two things into the drop-down this part is called as text and this part is called as values this section is used only to display the data to the user and this section is used to work with the database if you will update your language over here then it will not make any impact on to the value you can read some different text over here and there's some different text into the value from the database point of view we are only concerned about the value property you can write anything over here into this text section let's run this application click on the add new book link by default you can notice that you are getting English as a selected language and focus on the text the text is English and global language let's add some data to this form suppose somebody teen as sure that's their the author details description total pages click on the add book okay let's focus what we go into this model here you can notice that in the language property we are getting only English we are not getting the rest text because this data is coming from the value node from the text let's click on the continue button here you can see that the book has been added successfully to the database let us see further database and click on the books and choose so table data this time you can notice that we have two book into the database this is the second book and here you can see that the language is English if I want to add a new book with some other language then I can choose any language of my choice over here just focus on the text that is visible to the user so it means you can sow something different to the user and you can save some different value into your database let's focus on the HTML as well right click on this drop down and choose inspect here is the select tag and if you can notice that this is the value value is in the and text is something different value is English and the text is something different if you can notice that by default this English is selected why because we are passing this value from the controller and remember if we are using text and value both of them into your phone then you have to pass the value property from your controller if you will pass the text from your controller then it will not be selected you have to pass the value property what does it mean it means from this add new book X and matter you have to pass the value property for your language if you want to display Hindi into a selected language then you have to write Hindi and all other concepts that we have learned into the previous video all of them will be applicable to this drop-down as well it means if we choose this please add book language and click on the add book then click on the continue button you will see that we are getting an error message over here we have already covered this concept in the previous video of this tutorial in the next video of this tutorial we will create this drop-down by using the second approach make sure you hit the like button of this video subscribe to our channel and share this video thank you for watching have a great day
Info
Channel: WebGentle
Views: 8,857
Rating: undefined out of 5
Keywords: asp.net core, asp.net core tutorial, asp.net core 3.0, asp.net core 3.0 tutorial, asp.net core mvc 3.1, asp.net core mvc 3.1 tutorial, asp net mvc, asp net mvc tutorial, dotnet core, dotnet core mvc, asp.net mvc core 3, asp.net mvc core tutorial, asp.net mvc core course, dot net core tutorial, dot net core mvc tutorial, asp.net core 3.1, .net core, Dropdown in asp.net core with text and value property
Id: P1rWY4p7-S4
Channel Id: undefined
Length: 5min 3sec (303 seconds)
Published: Tue May 19 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.