Good afternoon,
I wanted to understand how this Key works, I have a function in aspx that I need in code-behind, but when I call it with a static Key, putting csname = "x";
It's only called once, but I need to be called as many times as possible I tried to put the name as a variable and it is never called, even without the if (!Page.ClientScript.IsStartupScriptRegistered(Page.GetType(), csname))
Here is the code, this code puts the items in the same row of a gridview, then it checks to see if you put the Expand icon in that row, so that it can be expanded when we click the icon.
protected void gvProduct_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink hlProcesso = (HyperLink)e.Row.FindControl("hlProcesso");
GridView gvRepetidos = (GridView)e.Row.FindControl("gvRepetidos");
DataTable dtNew = dtFormsFilhos.Clone();
bool isRepetido = false;
foreach (DataRow row in dtFormsFilhos.Rows)
{
if (row["ProcessoFilho"].ToString().Contains(hlProcesso.Text))
{
dtNew.Rows.Add(row.ItemArray);
isRepetido = true;
}
}
if (isRepetido)
{
//se coloco o csname como "x" ou "inclui", funciona 1x
//mas se coloco como está, não funciona. Não entendo como essa key funciona!
string csname = hlProcesso.Text.ToString();
string cstext = "IncluiExpand('" + hlProcesso.Text + "')";
if (!Page.ClientScript.IsStartupScriptRegistered(Page.GetType(), csname))
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), csname, cstext, true);
}
gvRepetidos.DataSource = dtNew;
gvRepetidos.DataBind();
}
}