Noms Nom

Noms Nom

  • 1.5k
  • 218
  • 805

input string was not in correct format .....

May 17 2019 11:49 AM
public partial class checkbox4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.DataSource = SqlDataSource1;
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox status = (row.Cells[3].FindControl("CheckBox1") as CheckBox);
int app_id = Convert.ToInt32(row.Cells[1].Text);
if (status.Checked)
{
updaterow(app_id, "A");
}
else
{
updaterow(app_id, "N");
}
}
Label1.Text = "Applications Has Been Approved Successfully";
SqlDataSource1.DataBind();
GridView1.DataSource = SqlDataSource1;
GridView1.DataBind();
}
private void updaterow(int app_id, String status)
{
String mycon = "Data Source=DESKTOP-F60JREG\\SQLEXPRESS;Initial Catalog=testhrm;Integrated Security=True";
String updatedata = "Update tbl_data set status='" + status + "' where id=" + app_id;
SqlConnection con = new SqlConnection(mycon);
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = updatedata;
cmd.Connection = con;
cmd.ExecuteNonQuery();
}
}

Answers (5)