简体   繁体   English

如何将数据网格绑定到devexpress comboBox

[英]how to bind a datagrid to a devexpress comboBox

ok folks i have a populated datagrid and my comboBox is populated all i need now is the knowledge on how to bind the datagrid to my AspxcomboBox 好的,我有一个填充的数据网格,并且我的comboBox已填充,现在我需要的是关于如何将数据网格绑定到我的AspxcomboBox的知识

i have done research on this i find precious little that makes sense to me in my situation. 我对此进行了研究,发现在我所处的情况下对我来说有意义的很少。 if you guys need to see my code i will provide it but i would rather not if possible.Just to clarify i did do research on this so i am not just asking for comfort-sake or convenience. 如果你们需要看到我的代码,我会提供,但是如果可能的话,我宁愿不提供。只是要澄清一下,我确实对此进行了研究,所以我不仅在要求舒适或方便。 i knew how to do this once upon a time but vb has ruined me any help or advice would be appreciated i am asking for assistance so keep the votedowns to a minimum 我曾经知道怎么做,但是vb毁了我任何帮助或建议,我将不胜感激,我需要帮助,所以请尽量减少投票

Have a look at this... it has a simple layout and uses a dropdown rather than combo but can be adapted. 看看这个...它的布局简单,使用下拉菜单而不是组合菜单,但可以进行调整。 If you run into any problems then let us know.... but supplying some code would be easier. 如果您遇到任何问题,请告诉我们...。但是提供一些代码会更容易。

http://www.aspsnippets.com/Articles/Filter-GridView-with-DropDownList-using-FilterExpression-in-SqlDataSource-in-ASPNet.aspx http://www.aspsnippets.com/Articles/Filter-GridView-with-DropDownList-using-FilterExpression-in-SqlDataSource-in-ASPNet.aspx

Check this site out maybe you might find what you are looking for. 查看此站点,也许您会找到所需的内容。

http://dotnetslackers.com/articles/aspnet/Custom_ASPNET_ComboxBox_Control.aspx http://dotnetslackers.com/articles/aspnet/Custom_ASPNET_ComboxBox_Control.aspx

You should follow the steps: 1- Define a asp:ObjectDataSource ID=" dgDataSource " for your datagrid. 您应该遵循以下步骤:1-为您的数据网格定义一个asp:ObjectDataSource ID =“ dgDataSource ”。 2- Define a asp:ObjectDataSource ID=" cbDataSource " for your ComboBox. 2-为您的ComboBox定义一个asp:ObjectDataSource ID =“ cbDataSource ”。 NOTE: Each of these 2 data sources are connected to a 2 different Models. 注意:这两个数据源中的每一个都连接到两个不同的模型。

<dx:ASPxGridView ID="myListGridView" ClientInstanceName="myListGridView" DataSourceID="dgDataSource"
    runat="server" AutoGenerateColumns="False" KeyFieldName="**field1Ofdg**"
    OnRowUpdated="myListGridView_RowUpdated">

<Columns>
    <dx:GridViewDataColumn FieldName="**field1Ofdg**" Caption="Code" Width="30%" >
        </dx:GridViewDataColumn>
    <dx:GridViewDataComboBoxColumn FieldName="**field2Ofdg**" ReadOnly="false" >  
        <PropertiesComboBox DataSourceID="cbDataSource" TextField="**LabelOfcb**" ValueField="**IdOfcb**"  >
        </PropertiesComboBox>
    </dx:GridViewDataComboBoxColumn>                   
</Columns>
</dx:ASPxGridView>

thes are the definitions for your data sources: 这些是您的数据源的定义:

<asp:ObjectDataSource ID="dgDataSource" runat="server" SelectMethod="GetMyDataForGridFunction" 
        UpdateMethod="UpdateDataForGridFunction" TypeName="namespace1"></asp:ObjectDataSource>

     <asp:ObjectDataSource ID="cbDataSource" runat="server" SelectMethod="GetMyDataForComboBoxFunction"
         TypeName="namespace2"></asp:ObjectDataSource>

NOTE: field1Ofdg and field1Ofdg are properties of Model1 Model of the grid. 注意: field1Ofdgfield1Ofdg是网格的Model1模型的属性。 LabelOfcb and IdOfcb are properties of Model2 model of the ComboBox. LabelOfcbIdOfcb是ComboBox的Model2模型的属性。

Keep me updated if it works fine to you :) 如果它对您有用,请及时通知我:)

Best Regards, ANDOURA 最好的问候,安杜拉

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM