0

I have code That work in create button dynamically in mvc. The problem is i have column call estates when we enter new estates ,it should create new button dyamically in the view page...

Here I done some of function it will create button using list.now i want to using sql column. When we enter new data in the sql column(Esates) it should create new button dyamically with the name what we entered in the sql column.

  List<Estates> estates = new List<Estates>
  {
    new Estates { Estate_ID = 1 , EstateName = "Annfiled"},
    new Estates { Estate_ID = 2 , EstateName = "Battalgalla"},
    new Estates { Estate_ID = 3 , EstateName = "Fordyce"},
   };

This view Code

@foreach (var item in Model)
{
    <button type="submit" id="Estate_id_Button" class="Estates_button">@item.EstateName
    </button>
}
Masoud Andalibi
  • 3,168
  • 5
  • 18
  • 44

1 Answers1

0

Use foreach loop to loop through your data and create buttons.

Kamsiinov
  • 1,315
  • 2
  • 20
  • 50