It can write out the cv.name, it also connects to the database. But I'm doing something wrong with a delete action.
cshtml:
<body>
@{
foreach( var cv in Model.GetCVs( username))
{
<h3 style="color: #193367; "><b> Name: @cv.name</b></h3> // this works
<form action="" method="post">
<input type="submit" name="name" value="@cv.name" /> // this works
</form>
@Html.ActionLink("Delete","Delete",new{ id = @cv.id}) // this does not work
}
}
</body>
The markup above is in my cshtml file and the most of it is working all right.
cshtml.cs:
[BindProperty]
public int id { get; set; }
public const string vv = "Data Source=Tables.sqlite3";
public static SqliteConnection Connection = new SqliteConnection(vv);
static AboutModel()
{
Connection.Open();
}
public struct CV
{
public string name;
public int id;
}
public ActionResult Delete(int? id)
{
using (var cmd = Connection.CreateCommand())
{
cmd.CommandText = "Delete from MyTable1 where id = @id;";
return RedirectToPage("About");
}
}
This is the code in my cshtml.cs
and the Delete
method is not working. I don't know how to properly use this delete
action. I don't want that it asks back that are you sure want to delete it? I just want that if the user click on the delete button, it should delete that row in a table.