ASPxGridView动态绑定数据

1. 每次都要先清楚一下列"Columns.Clear()",在绑定数据

.cs  

/// <summary>
    /// 动态创建gridview
    /// </summary>
    /// <param name="strFXFF"></param>
    private void CreateDynamicListColumn(string strFXFF)
    {
        DataSet dsList = InputByBatchData.InitCrossTabInfo(strFXFF);
        Session["dt_DynamicList"] = dsList.Tables["dtDynamic"];
        DataTable dt_DynamicList = dsList.Tables["dtDynamic"];
        Session["dtOriginalBig"] = dsList.Tables["dtOriginalBig"];
        DataTable dt_OriginalBig = dsList.Tables["dtOriginalBig"];
        InputByBatchIndexList.Columns.Clear();
      
        DevExpress.Web.ASPxGridView.GridViewCommandColumn columncheck = new GridViewCommandColumn();
      
        columncheck.Width = Unit.Parse("20px");
        columncheck.ShowSelectCheckbox = true;
       

        InputByBatchIndexList.Columns.Add(columncheck);

        DevExpress.Web.ASPxGridView.GridViewCommandColumn column = new GridViewCommandColumn();
        column.Caption = "修改";
        column.Width = Unit.Parse("60px");
        column.EditButton.Visible = true;
        column.EditButton.Text = "修改";
        InputByBatchIndexList.Columns.Add(column);
       
        InputByBatchIndexList.SettingsEditing.PopupEditFormModal = true;
       
        InputByBatchIndexList.SettingsEditing.PopupEditFormWidth = Unit.Parse("600px");
        InputByBatchIndexList.SettingsEditing.PopupEditFormAllowResize = true;
        foreach (DataColumn dc in dt_DynamicList.Columns)
        {
           
           
                GridViewDataColumn dataColumn1 = new GridViewDataColumn();
                dataColumn1.Caption = dc.ColumnName.ToString();

                //绑定列的字段
                dataColumn1.FieldName = dc.ColumnName.ToString();
                //ITemplate temp = new ItemTemplate(i);
                //dataColumn1.DataItemTemplate = new ItemTemplate(i);
                //dataColumn1.Visible = i;

                InputByBatchIndexList.Columns.Add(dataColumn1);


        }

    }

.aspx

<dxwgv:ASPxGridView ID="InputByBatchIndexList"
                                                        ClientInstanceName="InputByBatchIndexList"  AutoGenerateColumns="False"  runat="server"
                                                      KeyFieldName="试样编号"   Width="820px"  
                                                        OnRowUpdating="InputByBatchIndexList_RowUpdating"
                                                        onhtmldatacellprepared="InputByBatchIndexList_HtmlDataCellPrepared" OnCustomCallback="InputByBatchIndexList_CustomCallback">
                                                    <Settings ShowHorizontalScrollBar="True" />
                                                     <SettingsEditing Mode="PopupEditForm" PopupEditFormWidth="400px" />
                                                  <SettingsPager PageSize="10">
                                            <Summary AllPagesText="页数: {0} - {1} ({2} 条记录)" Text="第{0}页 共{1}页 (共{2}条记录)" />
                                        </SettingsPager>
                                           
</dxwgv:ASPxGridView>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值