This is a migrated thread and some comments may be shown as answers.

Trying to access GridTemplateColumn edititemtemplate controls from ItemCommand Event.

1 Answer 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 1
Brett asked on 11 Mar 2013, 08:51 PM
I am trying to access my radcomboboxes that are in my GridTemplateColumn when the Item command perform insert is fired.
protected void radGridAssetLocationHistory_ItemCommand(object sender, GridCommandEventArgs e)
{
     //Refresh Command Button was pressed
    if (e.CommandName == RadGrid.RebindGridCommandName)
    {
        radGridAssetLocationHistory.Rebind();
    }
    if (e.CommandName == RadGrid.PerformInsertCommandName)
    {
        //Need to access the items to perform insert
    }
}
<telerik:RadGrid ID="radGridAssetLocationHistory" runat="server" Skin="WebBlue" CellSpacing="0" GridLines="None" ShowStatusBar="True"
                    GroupingEnabled="False" OnNeedDataSource="radGridAssetLocationHistory_NeedDataSource" ShowFooter="True" AutoGenerateColumns="False" OnItemCommand="radGridAssetLocationHistory_ItemCommand" OnItemDataBound="radGridAssetLocationHistory_ItemDataBound">
                   <MasterTableView CommandItemDisplay="Top" DataKeyNames="TubularLocationID" InsertItemPageIndexAction="ShowItemOnCurrentPage" InsertItemDisplay="Top"  EditMode="InPlace">
                       <CommandItemSettings AddNewRecordText="Relocate Tubular To New Location" ShowRefreshButton="true"></CommandItemSettings>
                               <Columns>
                                    <telerik:GridEditCommandColumn UniqueName="CommandColumn" />
                                   <telerik:GridBoundColumn AllowFiltering="False" AllowSorting="False" DataField="TubularLocationID" DataType="System.Guid" Display="False" FilterControlAltText="Filter TubularLocationID column" Groupable="False" HeaderText="TubularLocationID" ReadOnly="True" ShowSortIcon="False" UniqueName="TubularLocationID">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn AllowFiltering="False" AllowSorting="False" DataField="TubularID" DataType="System.Guid" Display="False" FilterControlAltText="Filter TubularID column" Groupable="False" HeaderText="TubularID" ReadOnly="True" ShowSortIcon="False" UniqueName="TubularID">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn AllowFiltering="False" AllowSorting="False" DataField="LocationDate" DataType="System.DateTime" FilterControlAltText="Filter LocationDate column" Groupable="False" HeaderText="Location Date" ReadOnly="True" ShowSortIcon="False" UniqueName="LocationDate">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridTemplateColumn DataField="Region.Region1"  HeaderText="Region" UniqueName="Region" Display="true">
                                       <ItemTemplate><%# Eval("Region.Region1") %></ItemTemplate>
                                       <EditItemTemplate>
                                           <telerik:RadComboBox ID="radComboRegions" runat="server" Skin="" OnSelectedIndexChanged="radComboRegions_SelectedIndexChanged" AutoPostBack="true" CssClass="CustomRCB" DropDownWidth="200px" MarkFirstMatch="true" AllowCustomText="false" ></telerik:RadComboBox>
                                       </EditItemTemplate>
                                   </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn DataField="Facilit.Facility1"  HeaderText="Facility" UniqueName="Facility">
                                         <ItemTemplate><%# Eval("Facility.Facility1") %></ItemTemplate>
                                        <EditItemTemplate>
                                           <telerik:RadComboBox ID="radComboFacilities" runat="server" Skin="" CssClass="CustomRCB" OnSelectedIndexChanged="radComboFacilities_SelectedIndexChanged" AutoPostBack="true" DropDownWidth="200px" MarkFirstMatch="true" AllowCustomText="false" ></telerik:RadComboBox>
                                        </EditItemTemplate>
                                   </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn DataField="Region.Region1"  HeaderText="Area" UniqueName="Area">
                                         <ItemTemplate><%# Eval("Area.Area1") %></ItemTemplate>
                                         <EditItemTemplate>
                                           <telerik:RadComboBox ID="radComboAreas" runat="server" Skin="" CssClass="CustomRCB" DropDownWidth="200px" MarkFirstMatch="true" AllowCustomText="false" ></telerik:RadComboBox>
                                         </EditItemTemplate>
                                   </telerik:GridTemplateColumn>
                               </Columns>
                   </MasterTableView>
                   <FilterMenu EnableImageSprites="False"></FilterMenu>
               </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Brett
Top achievements
Rank 1
answered on 12 Mar 2013, 01:25 AM
I figured it out.

if (e.CommandName == RadGrid.PerformInsertCommandName)
            {
                //Need to access the items to perform insert
                GridDataInsertItem item = (GridDataInsertItem)e.Item;
                RadComboBox comboRegions = (RadComboBox)item.FindControl("radComboRegions");
                Label1.Text = comboRegions.SelectedValue;
            }
Tags
Grid
Asked by
Brett
Top achievements
Rank 1
Answers by
Brett
Top achievements
Rank 1
Share this question
or