0

我对开发快递很陌生。

<dx:ASPxGridView ID="aspxgvOMContracts" runat="server" KeyFieldName="OMContractId" Settings-UseFixedTableLayout="true"
                                AutoGenerateColumns="False" Settings-HorizontalScrollBarMode="Auto" Width="477px" Theme="PlasticBlue" 
                                OnRowUpdating="aspxgvOMContracts_OnRowUpdating" OnRowUpdated="aspxgvOMContracts_OnRowUpdated">
                                <SettingsPager PageSize="5" />
                                <SettingsBehavior AllowFocusedRow="true" />
                                <SettingsEditing Mode="Inline" />
                          <%--      <Styles>
                                    <CommandColumnItem Spacing="">
                                        <Paddings PaddingLeft="7" PaddingRight="7" />
                                    </CommandColumnItem>
                                </Styles>--%>
                                <Columns>
                                    <dx:GridViewCommandColumn ButtonType="Image" Width="65px" VisibleIndex="0">
                                        <EditButton Visible="True" Image-Url="../Content/Images/icon_edit.png">
                                        </EditButton>
                                        <UpdateButton Visible="True" Image-Url="../Content/Images/icon_update.png">
                                        </UpdateButton>
                                        <CancelButton Visible="true" Image-Url="../Content/Images/icon_cancel.png">
                                        </CancelButton>
                                        <DeleteButton Visible="true" Image-Url="../Content/Images/icon_delete.png">
                                        </DeleteButton>
                                        <ClearFilterButton Visible="True">
                                        </ClearFilterButton>
                                        <%--  <HeaderTemplate>
                                            <dx:ASPxLabel ID="headerLabel" runat="server">
                                            </dx:ASPxLabel>
                                        </HeaderTemplate>--%>
                                    </dx:GridViewCommandColumn>
                                    <dx:GridViewDataComboBoxColumn FieldName="OrganisationName" Caption="OrganisationName" VisibleIndex="1">
                                        <PropertiesComboBox TextField="CompanyName" ValueField="OrganisationId" ValueType="System.Int32">
                                        </PropertiesComboBox>
                                    </dx:GridViewDataComboBoxColumn>
                                    <dx:GridViewDataTimeEditColumn FieldName="DateAnnounced" Caption="DateAnnounced" VisibleIndex="2">
                                    </dx:GridViewDataTimeEditColumn>
                                    <dx:GridViewDataTextColumn FieldName="Cost" Caption="Cost" VisibleIndex="3">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn FieldName="CostCurrency" Caption="Cost Currency" VisibleIndex="4">
                                    </dx:GridViewDataTextColumn>
                                </Columns>

                            </dx:ASPxGridView>

在后面的代码中我将数据绑定为

aspxgvOMContracts.DataSource = phase.OMContracts;
        aspxgvOMContracts.DataBind();

这里 phase.OMContracts 是 List() 类型

现在,一旦我编辑任何行,我就需要修改后的集合。如何获得修改后的收藏?

4

1 回答 1

0

您已经分配了 AspxGridview 控件的 DataSource 属性,然后您可以直接访问从 DataSource 属性分配的分配List,它是一个读写属性。

检查文档:

ASPxDataWebControlBase.DataSource 属性

获取或设置数据绑定控件从中检索其数据项列表的对象。

From:获取 GridView 数据源到数据表

如果您在每个回发上绑定 gridview..那么您可以获得 DataTable dt = GridView1.DataSource as DataTable;

你也一样List<SomeType> data = grid.DataSource as List<SomeType>;

希望这有帮助..

于 2013-07-03T13:45:28.223 回答