This damned aspxdropdownedit, always can't solve the problem very well, spent a day without solving. Just revisit a Devexpree official website, found the legendary solution: the original official does not mention the use of Aspxdropdownedit, but highly recommended ComboBox.
The solution is as follows:
1,html Foreground Code
Note: The key is Sqldatasource,fieldname,textfield,valuefield,keyfieldname
<asp:SqlDataSource ID="sqlDataSrcApp" runat="server"></asp:SqlDataSource>
<asp:SqlDataSource ID="sqlDataSrcGroup" runat="server"></asp:SqlDataSource>
<dx:ASPxGridView ID="grvUserGroup" runat="server" AutoGenerateColumns="False"
ClientIDMode="AutoID"
CssFilePath="~/App_Themes/Office2003Blue/{0}/styles.css"
CssPostfix="Office2003Blue" Width="100%" KeyFieldName="AppID"
onrowinserting="grvUserGroup_RowInserting"
onrowupdating="grvUserGroup_RowUpdating"
onrowdeleting="grvUserGroup_RowDeleting"
oncelleditorinitialize="grvUserGroup_CellEditorInitialize" >
<ClientSideEvents RowDblClick="function(s, e) {
s.StartEditRow(e.visibleIndex);
}
<Columns>
< DX: gridviewdatacomboboxcolumn caption = "system name" fieldname = "appid"
VisibleIndex="0" >
<PropertiesComboBox ValueType="System.String" TextField="AppName"
ValueField="AppID" EnableSynchronization="False"
IncrementalFilteringMode="StartsWith" DataSourceID="sqlDataSrcApp" Width="100%">
</PropertiesComboBox>
<EditCellStyle HorizontalAlign="Left">
</EditCellStyle>
</dx:GridViewDataComboBoxColumn>
< DX: gridviewdatacomboxcolumn caption = "user group" fieldname = "groupid"
VisibleIndex="1">
<PropertiesComboBox ValueType="System.String" TextField="GroupName"
ValueField="GroupID" EnableSynchronization="False"
IncrementalFilteringMode="StartsWith" DataSourceID="sqlDataSrcGroup" Width="100%">
</PropertiesComboBox>
<EditCellStyle HorizontalAlign="Left">
</EditCellStyle>
</dx:GridViewDataComboBoxColumn>
</Columns>
<SettingsBehavior AllowFocusedRow="True" />
<SettingsEditing Mode="PopupEditForm" PopupEditFormHeight="80px"
PopupEditFormHorizontalAlign="WindowCenter" PopupEditFormModal="True"
PopupEditFormVerticalAlign="WindowCenter" PopupEditFormWidth="450px"
EditFormColumnCount="4" />
< settingstext commandcancel = "Cancel" commanddelete = "delete" commandedit = "modify"
Commandnew = "new" commandupdate = "OK" confirmdelete = "are you sure you want to delete" title = "modify user group information"
Popupeditformcaption = "modify user group information" / >
<Styles CssFilePath="~/App_Themes/Office2003Blue/{0}/styles.css"
CssPostfix="Office2003Blue">
<Header HorizontalAlign="Center">
</Header>
</Styles>
</dx:ASPxGridView>
2. Main background code (1)
// if(!) in form_load Enclosing IsPostBack) {-}
// the ellipsis section includes the following
SSQL = "select [AppID],[AppName] from [sysApp]";
SqlDataSrcApp. SelectCommand = sSQL;
SqlDataSrcApp. The ConnectionString = Common. ConfigHelper. GetConfigString (" ConnectionString ");
/ / = Common. Tool. GetDataTable (out sError sSQL);
If (! String. IsNullOrEmpty (sError)) {Common. MessageBox. Show (this, sError); The return; }
SSQL = "select [GroupID],[GroupName] from [sysGroup]";
SqlDataSrcGroup. SelectCommand = sSQL;
SqlDataSrcGroup. The ConnectionString = Common. ConfigHelper. GetConfigString (" ConnectionString ");
If (! String. IsNullOrEmpty (sError)) {Common. MessageBox. Show (this, sError); The return; }
3. Main background code (2)
Protected void grvUserGroup_CellEditorInitialize (object sender, DevExpress. Web. ASPxGridView. ASPxGridViewEditorEventArgs e)
{
String sSQL = string. The Empty;
If (grvUserGroup IsNewRowEditing && e.c. with our fabrication: olumn. FieldName = = "AppID")
{
SSQL = "select [AppID],[AppName] from [sysApp]";
SqlDataSrcApp. SelectCommand = sSQL;
SqlDataSrcApp. The ConnectionString = Common. ConfigHelper. GetConfigString (" ConnectionString ");
/ / = Common. Tool. GetDataTable (out sError sSQL);
If (! String. IsNullOrEmpty (sError)) {Common. MessageBox. Show (this, sError); The return; }
}
Else if (grvUserGroup IsNewRowEditing && e.c. with our fabrication: olumn. FieldName = = "GroupID")
{
SSQL = "select [GroupID],[GroupName] from [sysGroup]";
SqlDataSrcGroup. SelectCommand = sSQL;
SqlDataSrcGroup. The ConnectionString = Common. ConfigHelper. GetConfigString (" ConnectionString ");
If (! String. IsNullOrEmpty (sError)) {Common. MessageBox. Show (this, sError); The return; }
}
}
4, grvUserGroup_RowInserting, grvUserGroup_RowUpdating, grvUserGroup_RowDeleting implementation itself