I am struggling to add a ComboBox inside my RadGrid while Inserting/Updating my grid. So when my grid goes into editmode I want a ComboBox to be displayed.
Here is my aspx page:
<telerik:radgrid id="radManageMembers" runat="server" cssclass="GridView" width="96%"
autogeneratecolumns="true" onUpdateCommand="radManageMembers_UpdateCommand" Skin="WebBlue"
onNeedDataSource="radManageMembers_NeedDataSource" OnDeleteCommand="radManageMembers_DeleteCommand"
OnInsertCommand="radManageMembers_InsertCommand" OnItemCreated="radManageMembers_ItemCreated" OnItemCommand="radManageMembers_ItemCommand">
<MasterTableView EditMode="InPlace" AutoGenerateColumns="false"
TableLayout="Fixed" DataKeyNames="MemberID" CommandItemDisplay="TopAndBottom" Skin="WebBlue">
<Columns>
<telerik:GridBoundColumn DataField="MemberID" Display="false">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" ButtonType="PushButton" Text="Delete">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn DataField="MemberName" UniqueName="MemberName" HeaderText="MemberName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="FirstName" UniqueName="FirstName" HeaderText="FirstName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LastName" UniqueName="LastName" HeaderText="LastName" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Title" UniqueName="Title" HeaderText="Title">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="AdditionalNumber" UniqueName="AdditionalNumber" HeaderText="AdditionalNumber">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Telephone" UniqueName="Telephone" HeaderText="Telephone">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="IDNumber" UniqueName="IDNumber" HeaderText="IDNumber">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="BusinessName" UniqueName="BusinessName" HeaderText="BusinessName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Email" UniqueName="Email" HeaderText="Email">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LanguageCode" UniqueName="LanguageCode" HeaderText="LanguageCode">
</telerik:GridBoundColumn>
<telerik:GridEditCommandColumn ButtonType="PushButton" UniqueName="EditCommandColumn">
<HeaderStyle Width="85px"></HeaderStyle>
</telerik:GridEditCommandColumn>
</Columns>
<EditFormSettings CaptionFormatString="Edit details for employee with ID {0}" CaptionDataField="EmployeeID">
<FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle>
<FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle>
<FormStyle Width="100%"></FormStyle>
<EditColumn ButtonType="ImageButton">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<ClientSettings>
<ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
</ClientSettings>
I know you have to use the ItemCreated event but I can't get it to work exactly.
This is what I have in the ItemCreate, but this code doesn't work:
if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridCommandItem)
{
GridCommandItem insertItem = (GridCommandItem)e.Item;
RadComboBox combo = (RadComboBox)insertItem.FindControl("Title");
}
I have had a look at the example here - http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/editmodes/defaultcs.aspx
But this ComboBox does not populate distinct values from the database, there seems to be duplicates which I find pointless in a ComboBox.
I am open to see if there are alternative ways of doing this or the correct way of solving this problem.
Edit
The values for the ComboBox are from a database and all values are unique.