RadGrid There RadComboBox use FormTemplate edit control, automatic add, delete and update.
Click Edit when the RadComboBox can not be selected.
RadGrid and RadComboBox are two tables, the main foreign key relationship. How to RadComboBx select edit data. Thank you! ! !I use the Entity Data Source
Code:
Click Edit when the RadComboBox can not be selected.
RadGrid and RadComboBox are two tables, the main foreign key relationship. How to RadComboBx select edit data. Thank you! ! !I use the Entity Data Source
Code:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" |
AllowAutomaticUpdates="True" DataSourceID="EntityDataSource1" GridLines="None" |
OnItemUpdated="RadGrid1_ItemUpdated" OnInsertCommand="RadGrid1_InsertCommand" |
OnItemCommand="RadGrid1_ItemCommand"> |
<MasterTableView AutoGenerateColumns="False" HorizontalAlign="NotSet" CommandItemDisplay="TopAndBottom" |
DataKeyNames="DicID" DataSourceID="EntityDataSource1"> |
<Columns> |
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> |
</telerik:GridEditCommandColumn> |
<telerik:GridBoundColumn DataField="DicID" HeaderText="DicID" ReadOnly="false" SortExpression="DicID" |
UniqueName="DicID"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="DicDode" HeaderText="DicDode" SortExpression="DicDode" |
UniqueName="DicDode"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="DicName" HeaderText="DicName" SortExpression="DicName" |
UniqueName="DicName"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="DicRe" HeaderText="DicRe" SortExpression="DicRe" |
UniqueName="DicRe"> |
</telerik:GridBoundColumn> |
<telerik:GridDropDownColumn DataField="d_DicType.DicTypeID" DataSourceID="EntityDataSource2" |
ListTextField="TypeName" ListValueField="DicTypeID" HeaderText="d_DicType.DicTypeID" |
SortExpression="d_DicType.DicTypeID" UniqueName="d_DicType.DicTypeID"> |
</telerik:GridDropDownColumn> |
<telerik:GridButtonColumn HeaderText="Delete" ConfirmText="Delete this product?" |
ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" |
CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"> |
<ItemStyle HorizontalAlign="Center" /> |
</telerik:GridButtonColumn> |
</Columns> |
<EditFormSettings EditFormType="Template" ColumnNumber="2" CaptionDataField="RoleName"> |
<EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record" |
UniqueName="EditCommandColumn1" CancelText="Cancel edit"> |
</EditColumn> |
<FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" /> |
<FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" |
Width="100%" /> |
<FormTableItemStyle Wrap="False"></FormTableItemStyle> |
<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> |
<FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle> |
<FormTemplate> |
<table align="center" border="2" cellpadding="2" cellspacing="1" style="width: 100%; |
border-collapse: collapse;"> |
<tr> |
<td style="width: 100px; height: 40px"> |
<telerik:RadTextBox ID="DicID" runat="server" Text='<%# Bind("DicID") %>' Width="150px" |
Visible="false"> |
</telerik:RadTextBox> |
DicDode: |
</td> |
<td style="height: 30px"> |
<telerik:RadTextBox ID="RadTextBox_UserName" runat="server" Text='<%# Bind("DicDode") %>' |
Width="150px"> |
</telerik:RadTextBox> |
</td> |
<td style="width: 120px; height: 30px"> |
DicName: |
</td> |
<td style="height: 30px"> |
<telerik:RadTextBox ID="RadTextBox_LoginName" runat="server" Text='<%# Bind("DicName") %>' |
Width="150px"> |
</telerik:RadTextBox> |
</td> |
</tr> |
<tr> |
<td style="width: 100px; height: 40px"> |
DicRe: |
</td> |
<td style="height: 30px"> |
<telerik:RadTextBox ID="RadTextBox3" runat="server" Text='<%# Bind("DicRe") %>' Width="150px"> |
</telerik:RadTextBox> |
</td> |
<td style="width: 120px; height: 30px"> |
DicTypeID: |
</td> |
<td style="height: 30px"> |
<telerik:RadComboBox ID="ComboBox1" runat="server" DataSourceID="EntityDataSource2" |
DataTextField="TypeName" DataValueField="DicTypeID" AppendDataBoundItems="true" |
SelectedValue='<%# Bind("d_DicType.DicTypeID") %>'> |
</telerik:RadComboBox> |
</td> |
</tr> |
<tr> |
<td colspan="4" align="center"> |
<asp:Button ID="btnUpdate" runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' |
Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' /> |
<asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel" |
Text="Cancel" /> |
</td> |
</tr> |
</table> |
</FormTemplate> |
</EditFormSettings> |
</MasterTableView> |
</telerik:RadGrid> |
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=UnicornDBEntities" |
DefaultContainerName="UnicornDBEntities" EnableDelete="True" EnableInsert="True" |
EnableUpdate="True" EntitySetName="d_DicInfo" EntityTypeFilter="d_DicInfo"> |
</asp:EntityDataSource> |
<asp:EntityDataSource ID="EntityDataSource2" runat="server" ConnectionString="name=UnicornDBEntities" |
DefaultContainerName="UnicornDBEntities" EnableDelete="True" EnableInsert="True" |
EnableUpdate="True" EntitySetName="d_DicType"> |
</asp:EntityDataSource> |