Problem of using javascript in Radgrid item command event

3 posts, 0 answers
  1. MSyma
    MSyma avatar
    6 posts
    Member since:
    Oct 2012

    Posted 25 Jan 2013 Link to this post


    I' m facing the problem that is javascript funtion for open new tab doen't work in Radgrid item command event.Here is my Code for Item Command.

     protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
                  if (e.CommandName == "Customer")
                        lblID.Text = RadGrid2.Items[e.Item.ItemIndex].GetDataKeyValue("ID").ToString();
                        string strpath=  "../Report/Listing.aspx?ID=" + lblID.Text + "";
                        Response.Write("'" + strpath + "', '_newtab');");
    I do appreciate all suggestions.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Jan 2013 Link to this post


    I suppose you want to open a new tab in button click. Here is the sample code.
    protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
      if (e.CommandName == "open")
        GridDataItem item = (GridDataItem)e.Item;
        Button btn = (Button)item.FindControl("Button2");
        btn.Attributes.Add("onclick", "open");
    function open()
    {, '_newtab');

  3. Zaid
    Zaid avatar
    1 posts
    Member since:
    Oct 2014

    Posted 02 Feb Link to this post

    Hello..I'm having the similar problem,

    I have LinkButton inside RadGrid, on ItemCommand event handler i want to call a javascript function,please note that when i click on the LinkButton notheing happens but it works after that..please help

    below is sample of my code:

    telerik:GridTemplateColumn UniqueName="TemplateAddColumn">
                 <asp:LinkButton ID="lnkAdd" runat="server" Text="Add" Visible="false" CommandName="Add"></asp:LinkButton>
    LinkButton editLink = (LinkButton)e.Item.FindControl("lnkAdd");
    editLink.Attributes["href"] = "javascript:void(0);";
    editLink.Attributes["onclick"] = String.Format("return JSFunction('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["IndividualsID"], e.Item.ItemIndex);
Back to Top