Grid ItenDataBound InsertItemTemplate controls

2 posts, 0 answers
  1. Tom
    Tom avatar
    12 posts
    Member since:
    May 2013

    Posted 26 Jun 2015 Link to this post

    Is it possible to access controls in the InsertItemTemplate of the GridTemplateColumn? I have the following:

    <telerik:GridTemplateColumn UniqueName="Company" HeaderText="Company Name">
            <asp:Label ID="lblName" runat="server" Text='<%#Eval("Name")%>'></asp:Label>
           <telerik:RadAutoCompleteBox runat="server" ID="CompanyList" EmptyMessage="select company"></telerik:RadAutoCompleteBox>

    In the code behind I have:

    if (e.Item is GridEditableItem && e.Item.OwnerTableView.IsItemInserted)
        GridEditableItem item = e.Item as GridEditableItem;
        RadAutoCompleteBox ab = item["Company"].FindControl("CompanyList") as RadAutoCompleteBox;

    I also tried:

    if (e.Item is GridDataItem && e.Item.OwnerTableView.IsItemInserted)
        GridDataItem item = e.Item as GridDataItem;
        RadAutoCompleteBox ab = item["Company"].FindControl("CompanyList") as RadAutoCompleteBox;

    In both cases ab returns null. When I placed the control inside ItemTemplate, I get the control. I also tried using FindControl on e.Item and item itself and still get null. Basically I want to add a datasource to the autocomplete box only when inserting...on edit I only show the label. I want to bind the control using Telerik Data Access.


  2. Eyup
    Eyup avatar
    3956 posts

    Posted 01 Jul 2015 Link to this post

    Hello Tom,

    What EditMode do you use? You can examine the approaches provided in the following section to access the generated controls in the edit form:

    Hope this helps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top