Can't find linkbutton in command item template

6 posts, 0 answers
  1. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 22 May 2008 Link to this post

    In my application there is Rad grid, in its MasterTableView, there is DetailTables, in its GridTableView's CommandItemTemplate , i have taken one LinkButton.

    Problem is that I am not getting this linkbutton in ondetailtabledatabind event.

    I am giving code below..

    <telerik:RadGrid ID="grdExams" runat="server" ondetailtabledatabind="grdExams_DetailTableDataBind">

    <GroupPanel Visible="True">


    <MasterTableView GridLines="None" DataKeyNames="ID" DataSourceID="LinqDataSource1"

    CommandItemDisplay="TopAndBottom" Width="100%" Name="Examinations">


    <telerik:GridTableView HierarchyLoadMode="Client" DataSourceID="LinqDataSource2" DataKeyNames="ID"

    Width="100%" runat="server" CommandItemDisplay="Bottom" AllowAutomaticDeletes="true"

    AllowFilteringByColumn="false" Name="Detractions">


    <telerik:GridRelationFields MasterKeyField="ID" DetailKeyField="ExaminationID" />



    <PopUpSettings ScrollBars="None"></PopUpSettings>



    <asp:LinkButton ID="lnkAddDetraction" runat="server" CommandName="InitInsert" >

    I want to find the above link button "lnkAddDetraction"...


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 May 2008 Link to this post

    Hi Rahul,

    Try accessing the LinkButton in the CommandItemTemplate as shown below.

    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
             if ((e.Item is GridCommandItem) && (e.Item.OwnerTableView.Name == "Detractions")) 
                 GridCommandItem cmditm = (GridCommandItem)e.Item; 
                 LinkButton lnkbtn = (LinkButton)cmditm.FindControl("lnkAddDetraction"); 

    Hope this helps..
  3. DevCraft R3 2016 release webinar banner
  4. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 27 May 2008 Link to this post

    Hi Shinu,
    I want to find the linkbutton on ondetailtabledatabind event.
    there i cant get e.item..  which is easy to get on Databound.

    is there any other way?

  5. Sebastian
    Sebastian avatar
    9934 posts

    Posted 27 May 2008 Link to this post

    Hi Rahul,

    If you would like to modify settings for the link button inside the detail table's command item, the proper place to do that are the ItemCreated or ItemDataBound events of the grid. This will ensure that the viewstate and the event lifecycle of the link button will be consistent.

    More information about the ItemCreated/ItemDataBound events of RadGrid you can gather from this resource:

    Best regards,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 May 2008 Link to this post

    Hi Rahul,

    Try setting the EventHandler for the ItemDataBound event in the aspx as shown below.

     <telerik:RadGrid ID="RadGrid1" runat="server"  OnItemDataBound="RadGrid1_ItemDataBound"  OnDetailTableDataBind="RadGrid1_DetailTableDataBind" > 

  7. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 27 May 2008 Link to this post

    My problem of opening rad window on click on link button of grid have solved.
    Thanks alot for all your help,

    I have used this code in item data bound 

    protected void grdExams_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)



    ((e.Item is GridCommandItem) && (e.Item.OwnerTableView.Name == "Detractions"))


    GridCommandItem cmditm = (GridCommandItem)e.Item;

    LinkButton lnkbtn = (LinkButton)cmditm.FindControl("lnkAddDetraction");

    lnkbtn.OnClientClick =

    "window.radopen('Detractions/Edit.aspx','DetractionDialog');return false;";



    But now on telerik pop up i am using edit.aspx page.
    in this page i am using 

    <radT:RadTreeView ID="tvDetractionTypes" runat="server" DataTextField="Title" DataFieldID="ID"

    BeforeClientClick="handleNodeClick" DataValueField="ID" DataFieldParentID="ParentDetractionTypeID"

    Skin="Office2007" DataSourceID="dsDetractionTypes" Height="150px" Width="250px"



    and in java script 


    <script type="text/javascript">





    //if this is a parent node, expand it and select the first child


    if (node.Parent == null && node.Nodes.length > 0)





    return false;


    // Unlock any locked sliders


    SliderArrays[0][idxSliderLocked] =


    SliderArrays[1][idxSliderLocked] =


    SliderArrays[2][idxSliderLocked] =


    SliderArrays[3][idxSliderLocked] =


    // Make sliders visible


    SliderArrays[0][idxSliderDisplay] =


    SliderArrays[1][idxSliderDisplay] =


    SliderArrays[2][idxSliderDisplay] =


    SliderArrays[3][idxSliderDisplay] =


    // Redraw the sliders to reflect the new default values


    SliderArrays[0][idxSliderDisplayWeight] = node.Attributes[


    SliderArrays[1][idxSliderDisplayWeight] = node.Attributes[


    SliderArrays[2][idxSliderDisplayWeight] = node.Attributes[


    SliderArrays[3][idxSliderDisplayWeight] = node.Attributes[



    // Change the default DV


    var combo = <%= RecursiveFindControl("cboSeverity").ClientID %>;

    var item = combo.FindItemByValue(node.Attributes["DefaultDV"]);

    if (item != null) item.Select();

    //Change the tooltip text


    <%= RecursiveFindControl(

    "lnkTip").ClientID %>.title = node.Attributes["ChangeTip"];

    return true;



    Its giving run time error in the below line "exception is thrown"

    <%= RecursiveFindControl("lnkTip").ClientID %>.title = node.Attributes["ChangeTip"];

    if i removed the javascript and comment the <radT:RadTreeView it gives runtime error

    Cannot find a string resource with key 'ImageEditor' in App_GlobalResources/RadEditor.Tools.resx. Please, make sure that your custom localization has all needed resource strings, or copy the original localization resources from your installation folder to App_GlobalResources.

    please assist

Back to Top
DevCraft R3 2016 release webinar banner