private UnitsNavigatorTDS SubmitSearch()
        {
            // Retrieve clauses
            string whereClause = GetWhereClause();
            string orderByClause = GetOrderByClause();
            string conditionValue = "";

            UnitsNavigator unitsNavigator = new UnitsNavigator();
            string fmType = hdfFmType.Value;
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            // ... Load data
            FmTypeViewConditionGateway fmTypeViewConditionGateway = new FmTypeViewConditionGateway();
            fmTypeViewConditionGateway.LoadByFmTypeConditionId(fmType, companyId, int.Parse(ddlCondition1.SelectedValue));

            conditionValue = fmTypeViewConditionGateway.GetColumn_(fmType, companyId, int.Parse(ddlCondition1.SelectedValue));

            unitsNavigator.Load(whereClause, orderByClause, conditionValue, tbxCondition1.Text.Trim(), companyId);

            return (UnitsNavigatorTDS)unitsNavigator.Data;
        }
        private UnitsNavigatorTDS SubmitSearchForViews()
        {
            int viewId = Int32.Parse(ddlView.SelectedValue.Trim());
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            // ... Load SqlCommand
            FmViewGateway fmViewGateway = new FmViewGateway();
            fmViewGateway.LoadByViewId(viewId, companyId);

            string sqlCommand = "";
            sqlCommand = fmViewGateway.GetSqlCommand(viewId);

            // ... Load data
            string fmType = hdfFmType.Value.Trim();

            UnitsNavigator unitsNavigator = new UnitsNavigator();
            unitsNavigator.LoadForViewsFmTypeCompanyId(sqlCommand, fmType, companyId);

            return (UnitsNavigatorTDS)unitsNavigator.Data;
        }
        private void PostPageChanges()
        {
            UnitsNavigator unitsNavigator = new UnitsNavigator(unitsNavigatorTDS);

            // Update UnitsNavigator rows
            foreach (GridViewRow row in grdUnitsNavigator.Rows)
            {
                string unitIdLabel = ((Label)row.FindControl("lblUnitId")).Text.Trim();
                int unitId = Int32.Parse(unitIdLabel.ToString().Trim());
                bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;

                unitsNavigator.Update(unitId, selected);
            }

            unitsNavigator.Data.AcceptChanges();

            // Store datasets
            Session["unitsNavigatorTDS"] = unitsNavigatorTDS;
        }