简体   繁体   中英

How can I register a control with ClientScriptManager.RegisterForEventValidation

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;
    }

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);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM