Radio button and date's problem my ASP.NET

Harun Ergün 260 Reputation points
2023-05-11T14:22:07.8233333+00:00

Friends, first of all hello.

I'm designing a simple form site. But I'm getting an error. Texts are writing to the database, but the radio button and date does not write the error explodes. I left the whole code for you to review. I need helpUser's image

User's image

User's image

User's image

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,199 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,282 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,776 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,846 Reputation points
    2023-05-11T15:18:27.3766667+00:00

    The form[fieldname] method returns a string, which does not have a .Value() method. You use Int32.Parse() and DateTime.Parse().


  2. AgaveJoe 26,141 Reputation points
    2023-05-11T15:22:40.4533333+00:00

    I recommend that you learn MVC model binding which handles type validation and converting the post parameters into a type.

    If we go with your current approach, then you need to validate, which is not included, and convert the inputs yourself.

    DateTime dt = DateTime.ParseExact(Request.Form["LisansBasLangicTarihi"], "dd/MM/yyyy", CultureInfo.InvariantCulture);
    int num = int.Parse(Request.Form["Gender"]);