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

Discussion in 'ASP .Net' started by =?Utf-8?B?SmFpbWUgU3R1YXJkbw==?=, Dec 14, 2005.

  1. 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
    =?Utf-8?B?SmFpbWUgU3R1YXJkbw==?=, Dec 14, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Meade
    Replies:
    5
    Views:
    333
    Rob Meade
    Dec 10, 2003
  2. Andreas Klemt
    Replies:
    0
    Views:
    817
    Andreas Klemt
    Feb 1, 2004
  3. alanb
    Replies:
    2
    Views:
    517
    alanb
    Apr 23, 2004
  4. Jim Bancroft
    Replies:
    4
    Views:
    853
  5. Jim Bancroft
    Replies:
    4
    Views:
    163
Loading...

Share This Page