2013-02-26 122 views
2

我是新手C#程序员(大约6个月),我在当前使用ASP.NET的DevExpress组件中使用了DevExpress组件。使用aspxgridview的值填充GridViewDataComboBoxColumn

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

我在网站上看到了一些例子和线程,我试图实现但没有给我带来一些有效的结果。

的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”我有五个表要经过过滤数据,以获得帐户。 架构:标题> movement_title < financial_movement> content_movement < BANK_ACCOUNT 如果标题和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 (...) 

`

我需要一些帮助,做填充。 请,如果有人能帮助我,我在这里讨论... 谢谢。

回答

1

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

我穿上ASPX在我的GridView列

<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>和方法,在这里你有不完全相同的行为的资源: