How can I register a control with ClientScriptManager.RegisterForEventValidation

4.9k views Asked by At

I have gridview which I need to trigger inline editing from its code behind class. How to implement ClientScriptManager.RegisterForEventValidation.

<asp:GridView ID="gridViewTest" runat="server" 
        Height="145px" Width="369px" onrowdatabound="gv_RowDataBound" OnRowEditing="gv_RowEditing">
    </asp:GridView>

   protected void gv_RowEditing(object sender, GridViewEditEventArgs e)
    {
        gridViewTest.EditIndex = e.NewEditIndex;
    }
1

There are 1 answers

0
Xdrone On

Here is the solution for the above question:

     protected override void Render(HtmlTextWriter writer)
    {
        for (int i = 0; i < gridViewTest.Rows.Count; i++)
            ClientScript.RegisterForEventValidation(gridViewTest.UniqueID, "Edit$" + i);
        base.Render(writer);
    }