I am using C#. How can I display a success message if all data were submitted, or an error message and break the loop in case there was an error during the foreach loop?
This is my try, but I don't know the best way to display the messages:
protected void btnUpdate_Click(object sender, EventArgs e)
{
DataDTO data = new DataDTO();
BaseDAO coexion = new BaseDAO();
foreach (GridViewRow row in this.GridView1.Rows)
{
data.lblId = ((Label)row.FindControl("lblId")).Text;
try
{
coexion.update_database(data);
}
catch
{
// Display error message and break loop
}
}
GridView1.EditIndex = -1;
LoadGrid();
// Display success message
}
