예제 #1
0
        // 2005.01.09 - jorn, string optimize
        internal override void GetColumnPostBackData(RowCell cell)
        {
            try
            {
                string uniqueID = cell.CellClientId;
                if (Grid.GotHttpContext && HttpContext.Current.Request.Form[uniqueID] != null)
                {
                    cell.GotPostBackData = true;
                    cell.PostBackValue   = HttpContext.Current.Request.Form[uniqueID];
                    if (cell.PostBackValue == string.Empty)
                    {
                        cell.PostBackValue = null;
                        cell.Value         = null;
                    }
                    else
                    {
                        cell.Value = cell.PostBackValue;
                    }
                    Grid.State(uniqueID, cell.PostBackValue);
                }
                else
                {
                    if (!string.IsNullOrEmpty(Table.DataSourceId) &&
                        (Table.Columns == null || Table.Columns.Primarykeys.Count == 0))
                    {
                        throw new GridException(string.Format(
                                                    "No Primarykey was detected for foreign key column '{0}'.", Title));
                    }
                    // Check if we are using a mastergrid;
                    bool t1 = Grid.MasterWebGrid != null;

                    // Are we in detail view?
                    bool t3 = (Grid.DisplayView == DisplayView.Detail);

                    // Are we in insert-mode, not update-mode?
                    bool t6 = (Grid.InternalId == null);

                    bool t5 = cell.Value == null;

                    // Auto fill in
                    if (t1 && t3 && t5 && t6)
                    {
                        cell.Value = Grid.MasterWebGrid.InternalId;
                    }
                }
            }
            catch (Exception ee)
            {
                throw new GridException(string.Format("Error getting post back-data for foreign key '{0}' in Grid '{1}'", ColumnId, Grid.ID), ee);
            }
        }