2

我是一名新手 C# 程序员(大约 6 个月),我在当前使用 ASP.NET 的工作中使用 DevExpress 组件。

我不知道填充网格内的组合框。问题基本上是这样的:对于网格中的每一行,我都有一个要显示的标题/方坯,在一列中,我有支付该标题/方坯的银行账户列表。我需要在它们存在的地方显示至少一条记录,或者在尚未支付所有权/方坯时为空。

我在网站上查看了一些示例和线程,我尝试实现,但没有什么能给我带来一些有效的结果。

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”,我有五个表格要通过过滤数据来获取帐户。架构:标题>移动标题<金融移动>内容移动<银行帐户标题和金融移动将ID发送到移动标题等等关于“>”“<”信号......所以,我有一个包含重复标题和重复帐户的列表。在代码隐藏中,我可以执行此查询(使用 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 (...)

`

我需要一些帮助来填补。请,如果有人可以帮助我,我在这里讨论......谢谢。

4

1 回答 1

1

这是我的临时解决方案...

我在我的 GridView Columns 中放置了以下 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>和 方法的人来说,这里有一个资源可以做到这一点:

于 2013-02-27T19:41:40.647 回答