dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.29k stars 9.96k forks source link

[Blazor Server-Side]Creating a list in the razor file for multi-rows input #12147

Closed etcircle closed 5 years ago

etcircle commented 5 years ago

Hello,

I am trying to create a very simple scenario with multiple rows in one go. However, to get to that point I wanted to use a simple list. Following is my code. Admittedly, I am new to both C#/ASP.net so apologies if it is a user error.

Describe the bug

It is throwing CS1519, CS1031, CS8124, CS1026, CS1002 messages.

To Reproduce

//the definition of the properties is in a separate file public class NewRow { public string MaterialIdInp {get;set;} = String.Empty; public string QuantityInp {get;set;} = String.Empty; }

List matMvtNewDetails = new List(); matMvtNewDetails.Add(new NewRow()); //OR matMvtNewDetails.Add(new NewRow() {MaterialIdInp = "Hello", QuantityInp = "0" });

Expected behavior

I would expect to be able to create a list of class structure.

Screenshots

Pages\Materials\MaterialMvts.razor(159,25): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\Users\Name\Desktop\Learning\BusinessApp\BusinessApp.csproj] Pages\Materials\MaterialMvts.razor(159,26): error CS1031: Type expected [C:\Users\Name\Desktop\Learning\BusinessApp\BusinessApp.csproj] Pages\Materials\MaterialMvts.razor(159,26): error CS8124: Tuple must contain at least two elements. [C:\Users\Name\Desktop\Learning\BusinessApp\BusinessApp.csproj] Pages\Materials\MaterialMvts.razor(159,26): error CS1026: ) expected [C:\Users\Name\Desktop\Learning\BusinessApp\BusinessApp.csproj] Pages\Materials\MaterialMvts.razor(159,38): error CS1002: ; expected [C:\Users\Name\Desktop\Learning\BusinessApp\BusinessApp.csproj] Pages\Materials\MaterialMvts.razor(159,38): error CS1519: Invalid token ')' in class, struct, or interface member declaration [C:\Users\Name\Desktop\Learning\BusinessApp\BusinessApp.csproj]

Additional context

Add any other context about the problem here. Include the output of dotnet --info

.NET Core SDK (reflecting any global.json): Version: 3.0.100-preview6-012264 Commit: be3f0c1a03

Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\

Host (useful for support): Version: 3.0.0-preview6-27804-01 Commit: fdf81c6faf

.NET Core SDKs installed: 2.1.800-preview-009696 [C:\Program Files\dotnet\sdk] 2.2.300 [C:\Program Files\dotnet\sdk] 3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

etcircle commented 5 years ago

Sorry, silly me. I had to put it in a method...