Page.ClientScript.RegisterStartupScript method
Hello guys!
I need your help.
This is code behind in my net page (C#).
I use the Page.ClientScript.RegisterStartupScript method, but I need print in alert the resume numbers of strDAA variable.
If I have only one variable strDAA the script working, but if I have more numbers of variable strDAA the script print only last value.
I need resume all operation execute in my script in the alert window.
Could you please help?
Thanks you very much for your help
Code:
protected void btnUpdate_Click(object sender, EventArgs e)
{
OdbcCommand cmd = new OdbcCommand();
myConnectionString.Open();
cmd.Connection = myConnectionString;
int myValue = 0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkUpdate = (CheckBox)
GridView1.Rows[i].Cells[0].FindControl("chkSelect");
if (chkUpdate != null)
{
if (chkUpdate.Checked)
{
....
strDAA = ((TextBox)
GridView1.Rows[i].FindControl("DAA")).Text;
....
string myStringVariable = string.Empty;
myStringVariable = "OK for DAA " + strDAA + " ";
}
else
{
string myStringVariable = string.Empty;
myStringVariable = "Error for DAA " + strDAA + " ";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
myValue = 1;
}
}
}
}
if (myValue == 0)
{
GridViewBind();
}
Page.ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
myConnectionString.Close();
myConnectionString.Dispose();
}