0

我的页面上有两个网格视图。我想要做的是将第一个gridview 中的选定行复制到第二个gridview。

它使用下面的代码添加没有值的行。为什么不复制值?

添加行时没有值!

C#代码:

DataTable table = new DataTable();

table.Columns.Add("siteName", typeof(String));
table.Columns.Add("siteIP", typeof(String));

List<object> fieldValues = gridSiteList.GetSelectedFieldValues(new string[] { "siteName", "siteIP" });
foreach (object[] item in fieldValues)
{
    table.Rows.Add(item[0].ToString(), item[1].ToString());
}

gridReadyToGo.DataSource = table.DefaultView;
gridReadyToGo.DataBind();

ASP 代码:

<dx:ASPxGridView ID="gridSiteList" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3" KeyFieldName="siteName" Width="320px">
    <Columns>
        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="40px">
        </dx:GridViewCommandColumn>
        <dx:GridViewDataTextColumn FieldName="siteName" VisibleIndex="1" Width="135px" Caption="Name">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="siteIP" VisibleIndex="2" Width="135px" Caption="IP">
        </dx:GridViewDataTextColumn>
    </Columns>
    <settingsbehavior allowsort="False" />
    <settings showhorizontalscrollbar="True" showfilterrow="True" />
    <border borderstyle="Solid" borderwidth="1px"></border>
</dx:ASPxGridView>
<dx:ASPxGridView ID="gridReadyToGo" runat="server" AutoGenerateColumns="False" KeyFieldName="siteName" OnDataBinding="gridReadyToGo_DataBinding" Width="320px">
    <Columns>
        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="40px">
            <clearfilterbutton visible="True">
            </clearfilterbutton>
        </dx:GridViewCommandColumn>
        <dx:GridViewDataTextColumn Caption="Name" VisibleIndex="1" Width="135px">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn Caption="IP" VisibleIndex="2" Width="135px">
        </dx:GridViewDataTextColumn>
    </Columns>
    <settingsbehavior allowsort="False" />
    <settings showfilterrow="True" showhorizontalscrollbar="True" />
    <border borderstyle="Solid" borderwidth="1px"></border>
</dx:ASPxGridView>
4

0 回答 0