我是一名 C# 程序员新手(大约 6 个月),我在当前的 ASP.NET 工作中使用 DevExpress 组件。
我不知道如何填充网格内的组合框。 问题基本上是这样的: 对于网格中的每一行,我都有一个标题/方坯要显示,在一列中,我有这个标题/方坯支付时间的银行账户列表。 我需要在它们存在的地方至少显示一条记录,或者在尚未支付 title/billet 时为空。
我在网站上查看了一些示例和线程,我尝试实现但没有给我带来一些有效的结果。
aspx 看起来像这样: `
<dx:ASPxGridView ID="devGridView" ClientInstanceName="devGridView" runat="server"
AutoGenerateColumns="False" EnableCallBacks="False" KeyFieldName="ID_TITULO"
Width="100%" DataSourceID="odsTitulosReceber">
<Settings ShowHeaderFilterButton="true" ShowGroupPanel="true" ShowFooter="true" ShowFilterRow="true" />
<SettingsBehavior AllowFocusedRow="true" />
<SettingsDetail ShowDetailRow="true" />
<SettingsPager PageSize="100">
</SettingsPager>
<ClientSideEvents RowClick="behavior.rowClick" />
<Columns>
<dx:GridViewDataTextColumn FieldName="ID_DOCUMENTO_FISCAL" Caption="Doc. Fiscal"
Width="70px">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="DS_PESSOA" Caption="Pessoa">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="ST_TITULO" Caption="Situação">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="DT_EMISSAO" Caption="Emissão">
<PropertiesTextEdit DisplayFormatString="dd/MM/yyyy">
</PropertiesTextEdit>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="DT_VENCIMENTO" Caption="Vencimento">
<PropertiesTextEdit DisplayFormatString="dd/MM/yyyy">
</PropertiesTextEdit>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="DT_PAGAMENTO" Caption="Pagamento">
<PropertiesTextEdit DisplayFormatString="dd/MM/yyyy">
</PropertiesTextEdit>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="VL_TITULO" Caption="Valor" Width="110px">
<PropertiesTextEdit DisplayFormatString="c">
</PropertiesTextEdit>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="VL_PAGO" Caption="Valor Pago" Width="110px">
<PropertiesTextEdit DisplayFormatString="c">
</PropertiesTextEdit>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="VL_SALDO" Caption="Valor Saldo" Width="110px">
<PropertiesTextEdit DisplayFormatString="c">
</PropertiesTextEdit>
</dx:GridViewDataTextColumn>
<bold><dx:GridViewDataComboBoxColumn Caption="Pagamento Realizado" FieldName="CONTAS" >
<PropertiesComboBox TextField="DESCRIPTION" ValueField="ID">
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn></bold>
<dx:GridViewDataTextColumn FieldName="ID_TITULO" Caption="Título">
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
`
为了填充组合“Pagamento Realizado”,我有五个表要通过过滤数据来获取帐户。 架构:title > movement_title < financial_movement > content_movement < bank_account 其中 title 和 financial_movement 将 ID 发送到 movement_title 等等关于“>”“<”信号...... 所以,我有一个包含重复标题和重复帐户的列表。 在代码隐藏中,我可以执行此查询(使用 linq)以获取与正确标题相对应的指定帐户:
`
(...)
from ti in data.FINANCEIRO_TITULOs // TITULOS
join mt in data.FINANCEIRO_MOVIMENTOS_TITULOs on ti.NR_SEQ_TITULOS_FITI equals mt.NR_SEQ_TITULOS_FITI // MOVIMENTO_TITULOS
join mv in data.FINANCEIRO_MOVIMENTOs on mt.NR_SEQ_MOVIMENTO_FINANCEIRO_FIMF equals mv.NR_SEQ_MOVIMENTO_FINANCEIRO_FIMF // MOVIMENTOS
join cm in data.FINANCEIRO_CONTEUDO_MOVIMENTOs on mv.NR_SEQ_MOVIMENTO_FINANCEIRO_FIMF equals cm.NR_SEQ_MOVIMENTO_FINANCEIRO_FIMF // CONTEUDO_MOVIMENTOS
join co in data.FINANCEIRO_CONTAs on cm.NR_SEQ_CONTAS_FICO equals co.NR_SEQ_CONTAS_FICO // CONTAS
where
ti.TP_CREDITO_DEBITO_FITI == 2 && // credito
ti.ST_SITUACAO_FITI == 3 &&// baixado
ti.NR_SEQ_TITULOS_FITI.Equals(idTitulo)
select (...)
`
我需要一些帮助来完成填充。 拜托,如果有人可以帮助我,我在这里讨论... 谢谢。
最佳答案
这是我的临时解决方案...
我在我的 GridView 列中放置了以下 ASPx
<dx:GridViewDataColumn Caption="Pagamento Recebido" FieldName="CONTA">
<DataItemTemplate>
<asp:DropDownList DataTextField="Description" runat="server">
</asp:DropDownList>
</DataItemTemplate>
</dx:GridViewDataColumn>
如果我将查询作为数据源放入下拉列表。 这是一种糟糕的方式,因为页面加载非常缓慢,每次咨询都需要花费大量时间。
protected void devGridView_HtmlRowCreated(object sender, ASPxGridViewTableRowEventArgs e)
{
if (e.KeyValue != null) // avoid header and column name
{
ControlFinder<DropDownList> finder = new ControlFinder<DropDownList>();
finder.FindChildControlsRecursive(e.Row);
int idTitulo = e.GetValue("ID_TITULO").ToString().ToInt(); // necessary param
using (ErpDataLinq data = new ErpDataLinq())
{
finder.FoundControls.Each(f =>
{
f.DataSource = (
from ti in data.FINANCEIRO_TITULOs // TITULOS
join mt in data.FINANCEIRO_MOVIMENTOS_TITULOs on ti.NR_SEQ_TITULOS_FITI equals mt.NR_SEQ_TITULOS_FITI // MOVIMENTO_TITULOS
join mv in data.FINANCEIRO_MOVIMENTOs on mt.NR_SEQ_MOVIMENTO_FINANCEIRO_FIMF equals mv.NR_SEQ_MOVIMENTO_FINANCEIRO_FIMF // MOVIMENTOS
join cm in data.FINANCEIRO_CONTEUDO_MOVIMENTOs on mv.NR_SEQ_MOVIMENTO_FINANCEIRO_FIMF equals cm.NR_SEQ_MOVIMENTO_FINANCEIRO_FIMF // CONTEUDO_MOVIMENTOS
join co in data.FINANCEIRO_CONTAs on cm.NR_SEQ_CONTAS_FICO equals co.NR_SEQ_CONTAS_FICO // CONTAS
where
ti.TP_CREDITO_DEBITO_FITI == (byte)FinancialBase.OperationType.Credit && // 2 - credito
ti.ST_SITUACAO_FITI == (byte)Securities.Status.Closed && // 3 - baixado
ti.NR_SEQ_TITULOS_FITI.Equals(idTitulo) // param
select new { Description = co.NM_CONTA_FICO }).Distinct(); // distinct - to avoid duplicated values
f.DataBind();
});
}
}
}
好吧,这解决了我的问题。设计/布局丢失。我现在就试试让页面美观。
谢谢。
编辑
为谁试图理解 ControlFinder<T>
和方法,在这里你有一个资源可以执行完全相同的行为:
关于c# - 使用 aspxgridview 的值填充 GridViewDataComboBoxColumn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15094669/