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

How to get the value chosen from a RadComboBox that is inside RadGrid?

2 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Applejax
Top achievements
Rank 1
Applejax asked on 26 Feb 2015, 10:28 PM
Hello

I am using a RadComboBox inside a RadGrid.

The RadComboBox is populated by a web service.

The radgrid is being used as a form, where the user can input data to the grid (one row at a time) then click on "insert".

When the user clicks "insert" I need to get access to the value chosen by the user in the RadComboBox.

Below I have put my aspx and then my code-behind for the OnInsert event.

How can I finish my OnInsert event so that I have access to the value chosen by the user in the RadComboBox?


<telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false" AllowPaging="true"
                    OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateEditColumn="True" OnInsertCommand="RadGrid1_OnInsert" OnItemCreated="RadGrid1_ItemCreated" Width="99%" OnPreRender="RadGrid1_PreRender">
                    <MasterTableView  runat="server" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="InPlace" Width="100%" TableLayout="Auto">
                    <Columns>
                         
                      <telerik:GridTemplateColumn UniqueName="UserCol" HeaderText="proto user" DataField="UserID">
                            
                           <EditItemTemplate>
                               <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="false" CausesValidation="true"
                                            Width="240" MaxHeight="200px" OnItemsRequested="ddEmployee_ItemsRequested" AllowCustomText="true"
                                            EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
                                            MarkFirstMatch="false" >
                                </telerik:RadComboBox>
                           </EditItemTemplate>
                       </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="FromFloor" HeaderText="From Floor" UniqueName="FFCol" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="FromStation" HeaderText="From Station" UniqueName="FSCol" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ToFloor" HeaderText="To Floor" UniqueName="TFCol" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ToStation" HeaderText="To Station" UniqueName="TSCol" ></telerik:GridBoundColumn>
                        <telerik:GridDateTimeColumn DataField="DateToRelocate" HeaderText="Date To Relocate" UniqueName="DateCol" ></telerik:GridDateTimeColumn>
                                         
                    </Columns>
                </MasterTableView>
                </telerik:RadGrid>


protected void RadGrid1_OnInsert(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
 
 
 
 
            GridEditableItem editedItem = e.Item as GridEditableItem;
            GridEditManager editMan = editedItem.EditManager;
            foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)
            {
                if (column is IGridEditableColumn)
                {
                    IGridEditableColumn editableCol = (column as IGridEditableColumn);
                    if (editableCol.IsEditable)
                    {
                        IGridColumnEditor editor = editMan.GetColumnEditor(editableCol);
 
                        string editorText = "unknown";
                        object editorValue = null;
 
                        if (editor is GridTemplateColumnEditor)
                        {
 
 
                        }
 
                        if (editor is GridTextColumnEditor)
                        {
                            editorText = (editor as GridTextColumnEditor).Text;
                            editorValue = (editor as GridTextColumnEditor).Text;
                        }
 
 
                    }
                }
            }
 
        }




2 Answers, 1 is accepted

Sort by
0
Applejax
Top achievements
Rank 1
answered on 26 Feb 2015, 10:33 PM
Also please note that I cannot search for a specific radComboBox because they are added dynamically everytime the user wants to add another row of data to the table
0
Dimitar
Telerik team
answered on 03 Mar 2015, 12:41 PM
Hi,

We have a special Combo in Grid demo which shows how you could integrate the two controls.
It would help you solve the problem faces. Let us know, if you need further assistance.

Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Applejax
Top achievements
Rank 1
Answers by
Applejax
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or