当我尝试在我的项目中实现DropDownEditor Control时,我遇到了问题。
这是网站中的示例代码点击here
这是我的代码:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Listar" TypeName="AlsaGroup.Alsa.AlsaWeb.BusinessLogic.ServicioBL" InsertMethod="Agregar">
<InsertParameters>
<asp:Parameter Name="nombreServicio" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
<dx:ASPxDropDownEdit ID="DDLEditServicio" runat="server" ClientInstanceName="DDLEditServicio"
Width="170px" AllowUserInput="False" AnimationType="None">
<DropDownWindowStyle>
<Border BorderWidth="0px" />
</DropDownWindowStyle>
<DropDownWindowTemplate>
<dx:ASPxGridView ID="GridView" runat="server" AutoGenerateColumns="False" ClientInstanceName="GridView"
Width="500px" DataSourceID="ObjectDataSource1" KeyFieldName="Cod_Serv" OnRowInserting="GridView_RowInserting"
OnInitNewRow="GridView_InitNewRow" OnCustomJSProperties="GridView_CustomJSProperties"
OnAfterPerformCallback="GridView_AfterPerformCallback">
<Columns>
<dx:GridViewCommandColumn VisibleIndex="0">
<NewButton Visible="True">
</NewButton>
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="Cod_Serv" VisibleIndex="1" ReadOnly="True" Caption="Cod. Serv.">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Des_Serv" VisibleIndex="2" Caption="Descripcion ">
</dx:GridViewDataTextColumn>
</Columns>
<ClientSideEvents Init="GridViewInitHandler" RowClick="RowClickHandler" EndCallback="EndCallbackHandler" />
<Settings VerticalScrollBarMode="Visible" />
<SettingsBehavior ConfirmDelete="True" EnableRowHotTrack="True" AllowFocusedRow="True" />
<SettingsPager Mode="ShowAllRecords" />
</dx:ASPxGridView>
</DropDownWindowTemplate>
</dx:ASPxDropDownEdit>
这是C#中的代码:
protected void GridView_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
{
var grid = sender as ASPxGridView;
//e.NewValues["Cod_Serv"] = AlsaGroup.Alsa.AlsaWeb.BusinessLogic.ServicioBL.Instancia.Agregar("xxx")
//e.NewValues["ID"] = EmployeeSessionProvider.GenerateNewID();
}
protected void GridView_AfterPerformCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewAfterPerformCallbackEventArgs e)
{
SynchronizeFocusedRow();
}
private void SynchronizeFocusedRow()
{
var grid = (ASPxGridView)DDLEditServicio.FindControl("GridView");
var lookupKeyValue = DDLEditServicio.KeyValue;
grid.FocusedRowIndex = grid.FindVisibleIndexByKeyValue(lookupKeyValue);
}
protected void GridView_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
{
var grid = sender as ASPxGridView;
if (grid != null) grid.ScrollToVisibleIndexOnClient = 0;
}
protected void GridView_CustomJSProperties(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewClientJSPropertiesEventArgs e)
{
var grid = (ASPxGridView)DDLEditServicio.FindControl("GridView");
var servicioLista = new object[grid.VisibleRowCount];
var keyValues = new object[grid.VisibleRowCount];
for (var i = 0; i < grid.VisibleRowCount; i++)
{
servicioLista[i] = grid.GetRowValues(i, "Des_Serv"); //+ " " + grid.GetRowValues(i, "LastName");
keyValues[i] = grid.GetRowValues(i, "Cod_Serv");
}
e.Properties["cpDes_Serv"] = servicioLista;
e.Properties["cpCod_Serv"] = keyValues;
}
我的问题是在插入新值的事件中,在示例中我看到一个新事件NewGenerateID(),我怎么有一个方法在插入数据时返回一个新值,但我需要一个ParameterValue。
我配置了一个ObjectDataSource,它映射了要插入和选择的方法,出了什么问题?