Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4162

onclick function not working in Blazor Maui App

$
0
0

I want to update an SQL table by checking/unchecking the checkbox in Blazor Maui Hybrid app. No matter what I try, it won't change anything in the SQL table because the function is not being called.Here's the code for the checkbox:

<th><input type="checkbox" checked = "@equipment.IsCheckedOut" onclick="CheckOutEquipment(@equipment);"></th>

Here's the function it calls:

public void CheckOutEquipment(Equipment equipment){    MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder        {            Server = "localhost",            UserID = "root",            Password = "password",            Database = "demo211",        };    MySqlConnection connection = new MySqlConnection(builder.ConnectionString);    connection.Open();    string update = $"update Equipment set CheckedOut = 1 where ID={equipment.ID}";    MySqlCommand updateCmd = new MySqlCommand(update,connection);    updateCmd.ExecuteNonQuery();    connection.Close();}

Viewing all articles
Browse latest Browse all 4162

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>