Calling grid and child events from clientside

2 posts, 0 answers
  1. BRK
    BRK avatar
    35 posts
    Member since:
    Jun 2012

    Posted 10 May 2011 Link to this post

    Hi Friends,

    I want to display lots of data in RadGrid in which there will be some child controls in the grid which are having some events.
    My point is here.. with this huge data if I call those events from server side it will definitely takes some time. I want a solution to
    reduce the time using any client side techniques.
    How to call events using Javascript client side techniques?
    If anyone of you know help please help me in this connection.

    Thanking you,
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 May 2011 Link to this post

    Hello Bharath,

    You can attach the client events to the child controls either from aspx or from code behind. Here is the sample code.

    From aspx:
    <telerik:GridTemplateColumn UniqueName="TemplateCol">
           <asp:Button ID="Btn1" runat="server" Text="Button1" OnClientClick="showAlert();" />
    function showAlert()
            alert("Button Clicked");

    For attaching from server side, hook ItemCreated and try the following.
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
           if (e.Item is GridDataItem)
               GridDataItem item = (GridDataItem)e.Item;
               Button btn = (Button)item.FindControl("Btn1");
               btn.Attributes.Add("onclick", "showalert(" + e.Item.ItemIndex +")");

    function showalert(index)

Back to Top