Problem adding an attribute to a web form control after posting ba

G

Guest

Hi all...

I have the following curious problem,

I have a GridView that I bind after I press a button in the web form. That
grid has a template column, which contains a checkbox (in the header and in
each row). The grid view is configured to be sortable.

These are the event handlers that causes the post back (click for the button
and when the grid has to be sorted)

protected void btnCargar_Click(object sender, EventArgs e)
{
ViewState["sort_expresion"] = "NUMPOL";
ViewState["sort_direction"] = "";

RefreshdataGrid();
}
protected void gvClaveInternet_Sorting(object sender,
GridViewSortEventArgs e)
{
ViewState["sort_expresion"] = e.SortExpression;
ViewState["sort_direction"] = e.SortDirection;

RefreshdataGrid();
}

RefreshdataGrid( ) method contains this code :

((CheckBox)gvClaveInternet.HeaderRow.Cells[0].Controls[1]).Attributes.Add("onclick", "check_all();");
foreach (GridViewRow row in gvClaveInternet.Rows)
((CheckBox)row.Cells[0].Controls[1]).Attributes.Add("onclick",
"row_click();");

btnDesmarcar.Attributes.Add("onclick", "return confirm('¿Está seguro que
desea proceder?');");


Well... when the page is loaded after btnCargar_Click event occurs,
"onclick" attribute is correctly added to the checkboxes, but when I press
some header text in order to sort by that column and the page is refreshed,
the "onclick" attribute isn't added to the checkboxes, but it is added for
btnDesmarcar button, so it's a problem only for the checkboxes.

When I debug the application, I see that the code is correctly executed.

What may be hapenning?
Thanks in advance

Jaime
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top