Esempio n. 1
0
        /// <summary>
        /// FineUIPro.Grid控件的数据转换成DataTable
        /// </summary>
        /// <param name="grid">Grid控件</param>
        /// <returns>DataTable数据源</returns>
        public static DataTable GridDataGet(FineUIPro.Grid grid, FineUIPro.GridRowCollection rows)
        {
            int       rowCount = 0;
            DataTable dtGrid   = new DataTable();

            foreach (GridColumn gc in grid.Columns)
            {
                if (gc is FineUIPro.BoundField)
                {
                    dtGrid.Columns.Add(new DataColumn(((FineUIPro.BoundField)(gc)).DataField.ToUpper(), typeof(string)));
                }
                else if (gc is FineUIPro.RenderField)
                {
                    dtGrid.Columns.Add(new DataColumn(((FineUIPro.RenderField)(gc)).DataField.ToUpper(), typeof(string)));
                }
                else if (gc is FineUIPro.TemplateField)
                {
                    dtGrid.Columns.Add(new DataColumn(((FineUIPro.TemplateField)(gc)).ColumnID.ToUpper(), typeof(string)));
                }
                rowCount++;
            }
            if (rowCount > 0)
            {
                foreach (GridRow gr in rows)
                {
                    DataRow row = dtGrid.NewRow();
                    foreach (GridColumn gc in grid.Columns)
                    {
                        if (gc is FineUIPro.BoundField)
                        {
                            row[((FineUIPro.BoundField)(gc)).DataField.ToUpper()] = gr.Values[gc.ColumnIndex];
                        }
                        if (gc is FineUIPro.RenderField)
                        {
                            row[((FineUIPro.RenderField)(gc)).DataField.ToUpper()] = gr.Values[gc.ColumnIndex];
                        }
                        else if (gc is FineUIPro.TemplateField)
                        {
                            row[((FineUIPro.TemplateField)(gc)).ColumnID.ToUpper()] = gr.Values[gc.ColumnIndex];
                        }
                    }
                    dtGrid.Rows.Add(row);
                }
            }
            return(dtGrid);
        }
Esempio n. 2
0
        protected void btnSure_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            if (GoodsInfo.SelectedRowIndexArray.Length == 0)
            {
                Alert.Show("请选择商品信息!", "警告提醒", MessageBoxIcon.Warning);
                return;
            }
            FineUIPro.GridRowCollection rows = new FineUIPro.GridRowCollection();
            for (int i = GoodsInfo.SelectedRowIndexArray.Length - 1; i > -1; i--)
            {
                rows.Add(GoodsInfo.Rows[GoodsInfo.SelectedRowIndexArray[i]]);
            }
            dt = GridDataGet(GoodsInfo, rows);

            DataGridBack(dt);
        }