i want to save each row which checked using sqldatasource, but i got error The variable name '@Approved_By' has already been declared. Variable names must be unique within a query batch or stored procedure.
am i wrong in looping?
int i = 0;
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkRow = (row.Cells[2].FindControl("CheckBox1") as CheckBox);
bool chk = chkRow.Checked;
if (chk = chkRow.Checked)
{
SqlDataSource3.UpdateParameters.Add("Approved_By", Session["username"].ToString());
SqlDataSource3.UpdateParameters.Add("Kode_Personel", GridView1.Rows[row.RowIndex].Cells[0].Text);
SqlDataSource3.Update();
}
}
i++;
}
SqlDataSource3.UpdateParameters.Clear()before addingUpdateParametersin foreach loop? Is that work?