チェンジセット 1633 (default)


以下の違いを無視:
日時:
2024/02/12 2:49:43 (8ヵ月前)
更新者:
hizuya@…
ログメッセージ:
  • GridView の行内に複数列をにわたり同じグループの RadioButton を配置し、それぞれの行で選択した値を取得する機能を追加。
  • GridView の DataKeys を使う機能を呼び出したときに DataKeyNames プロパティが指定されていなければ専用の例外を投げるように変更。
場所:
framework/trunk
ファイル:
5個の追加
6個の更新

凡例:

未変更
追加
削除
  • framework/trunk/WebApplication/WebApplication.csproj

    r1632 r1633  
    7171    <Content Include="UI\WebControls\FormViewBindUserControl1.ascx" /> 
    7272    <Content Include="UI\WebControls\FormViewPage.aspx" /> 
     73    <Content Include="UI\WebControls\RadioButtonFieldPage.aspx" /> 
    7374    <Content Include="UI\WebControls\TemplateFieldPage.aspx" /> 
    7475    <Content Include="UI\WebControls\ObjectDataSourceGridViewPage.aspx" /> 
     
    339340    <Compile Include="UI\Parameter\ParameterMemberPage.aspx.designer.cs"> 
    340341      <DependentUpon>ParameterMemberPage.aspx</DependentUpon> 
     342    </Compile> 
     343    <Compile Include="UI\WebControls\RadioButtonFieldPage.aspx.cs"> 
     344      <DependentUpon>RadioButtonFieldPage.aspx</DependentUpon> 
     345      <SubType>ASPXCodeBehind</SubType> 
     346    </Compile> 
     347    <Compile Include="UI\WebControls\RadioButtonFieldPage.aspx.designer.cs"> 
     348      <DependentUpon>RadioButtonFieldPage.aspx</DependentUpon> 
    341349    </Compile> 
    342350    <Compile Include="UI\WebControls\TemplateFieldPage.aspx.cs"> 
     
    602610    <None Include="App_Data\SqlTemplates\UI\WebControls\JQueryImageButtonFieldPage.st" /> 
    603611    <None Include="App_Data\SqlTemplates\UI\WebControls\PageMemberParameterPage.st" /> 
     612    <Content Include="App_Data\SqlTemplates\UI\WebControls\RadioButtonFieldPage.st" /> 
    604613    <None Include="App_Data\SqlTemplates\UI\WebControls\RowStyleFieldPage.st" /> 
    605614    <Content Include="App_Data\SqlTemplates\UI\WebControls\SelectFieldBoundInnerGridViewPage.st" /> 
  • framework/trunk/WebLibrary/Properties/Resources.designer.cs

    r1616 r1633  
    824824         
    825825        /// <summary> 
     826        ///   The value type &apos;{1}&apos; bound to RadioButtonField &apos;{0}&apos; cannot be converted from a string. に類似しているローカライズされた文字列を検索します。 
     827        /// </summary> 
     828        internal static string Http_RadioButtonField_CannotConvertFromString { 
     829            get { 
     830                return ResourceManager.GetString("Http_RadioButtonField_CannotConvertFromString", resourceCulture); 
     831            } 
     832        } 
     833         
     834        /// <summary> 
     835        ///   ValueToCompare value &apos;{2}&apos; of RadioButtonField &apos;{0}&apos; cannot be converted to bound value type &apos;{1}&apos;. に類似しているローカライズされた文字列を検索します。 
     836        /// </summary> 
     837        internal static string Http_RadioButtonField_CannotConvertValueToCompare { 
     838            get { 
     839                return ResourceManager.GetString("Http_RadioButtonField_CannotConvertValueToCompare", resourceCulture); 
     840            } 
     841        } 
     842         
     843        /// <summary> 
     844        ///   RadioButtonField &apos;{0}&apos; contains a control that isn&apos;t a RadioButton.  Override OnDataBindField to inherit from RadioButtonField and add different controls. に類似しているローカライズされた文字列を検索します。 
     845        /// </summary> 
     846        internal static string Http_RadioButtonField_WrongControlType { 
     847            get { 
     848                return ResourceManager.GetString("Http_RadioButtonField_WrongControlType", resourceCulture); 
     849            } 
     850        } 
     851         
     852        /// <summary> 
    826853        ///   Server operation is not available in this context. に類似しているローカライズされた文字列を検索します。 
    827854        /// </summary> 
     
    10181045            get { 
    10191046                return ResourceManager.GetString("InvalidOperation_CouldNotFindControl", resourceCulture); 
     1047            } 
     1048        } 
     1049         
     1050        /// <summary> 
     1051        ///   Data keys must be specified on GridView &apos;{0}&apos; before the data keys can be retrieved.  Use the DataKeyNames property to specify data keys. に類似しているローカライズされた文字列を検索します。 
     1052        /// </summary> 
     1053        internal static string InvalidOperation_GridView_DataKeyNamesMustBeSpecified { 
     1054            get { 
     1055                return ResourceManager.GetString("InvalidOperation_GridView_DataKeyNamesMustBeSpecified", resourceCulture); 
    10201056            } 
    10211057        } 
     
    19682004         
    19692005        /// <summary> 
     2006        ///   The property {1} is not supported on {0}. に類似しているローカライズされた文字列を検索します。 
     2007        /// </summary> 
     2008        internal static string NotSupported_Property { 
     2009            get { 
     2010                return ResourceManager.GetString("NotSupported_Property", resourceCulture); 
     2011            } 
     2012        } 
     2013         
     2014        /// <summary> 
    19702015        ///   Property is read only. に類似しているローカライズされた文字列を検索します。 
    19712016        /// </summary> 
  • framework/trunk/WebLibrary/Properties/Resources.resx

    r1616 r1633  
    937937    <value>LinkedPropertyPositiveValue and LinkedPropertyNegativeValue must be a settable value for the property in ControlPropertyLinkageConnector '{0}'.</value> 
    938938  </data> 
     939  <data name="Http_RadioButtonField_WrongControlType" xml:space="preserve"> 
     940    <value>RadioButtonField '{0}' contains a control that isn't a RadioButton.  Override OnDataBindField to inherit from RadioButtonField and add different controls.</value> 
     941  </data> 
     942  <data name="Http_RadioButtonField_CannotConvertFromString" xml:space="preserve"> 
     943    <value>The value type '{1}' bound to RadioButtonField '{0}' cannot be converted from a string.</value> 
     944  </data> 
     945  <data name="Http_RadioButtonField_CannotConvertValueToCompare" xml:space="preserve"> 
     946    <value>ValueToCompare value '{2}' of RadioButtonField '{0}' cannot be converted to bound value type '{1}'.</value> 
     947  </data> 
     948  <data name="NotSupported_Property" xml:space="preserve"> 
     949    <value>The property {1} is not supported on {0}.</value> 
     950  </data> 
     951  <data name="InvalidOperation_GridView_DataKeyNamesMustBeSpecified" xml:space="preserve"> 
     952    <value>Data keys must be specified on GridView '{0}' before the data keys can be retrieved.  Use the DataKeyNames property to specify data keys.</value> 
     953  </data> 
    939954</root> 
  • framework/trunk/WebLibrary/Sources/UI/WebControls/GridView.cs

    r1604 r1633  
    2626    using System.Collections; 
    2727    using System.Collections.Generic; 
     28    using System.Collections.Specialized; 
    2829    using System.ComponentModel; 
     30    using System.Diagnostics; 
     31    using System.Globalization; 
    2932    using System.Reflection; 
    3033    using System.Web; 
    3134    using System.Web.UI; 
    3235    using System.Web.UI.WebControls; 
     36    using FCSoft.SilverFrost.Framework.Collection; 
    3337    using FCSoft.SilverFrost.Framework.Reflection; 
     38    using FCSoft.SilverFrost.Framework.Web.Properties; 
    3439 
    3540 
     
    180185            get 
    181186            { 
     187                EnsureDataKeys(); 
     188 
    182189                int targetIndex = GetSelectFieldIndex(); 
    183190                if (targetIndex == -1) 
     
    211218            get 
    212219            { 
     220                EnsureDataKeys(); 
     221 
    213222                List<int> targetIndexes = new List<int>(); 
    214223                DataControlFieldCollection columns = Columns; 
     
    287296            get 
    288297            { 
     298                EnsureDataKeys(); 
     299 
    289300                int targetIndex = GetSelectFieldIndex(); 
    290301                if (targetIndex == -1) 
     
    314325                if (Rows.Count != 0) 
    315326                { 
     327                    EnsureDataKeys(); 
    316328                    UpdateSelectFieldState(); 
    317329                } 
     
    544556 
    545557        /// <summary> 
     558        /// 指定したデータフィールド名に対応する値の一覧を返します。 
     559        /// </summary> 
     560        /// <param name="dataField">データフィールド名。</param> 
     561        /// <returns> 
     562        /// 対応するデータフィールドにバインドされたデータのディクショナリです。 
     563        /// レコードを識別するための <see cref="DataKey"/> をキーとして、 
     564        /// バインドされた値を値として格納されています。 
     565        /// 表示されている行の順番で格納されています。 
     566        /// </returns> 
     567        /// <remarks> 
     568        /// 現在このメソッドで取得可能なバインドフィールドは 
     569        /// <see cref="RadioButtonField"/> のみです。 
     570        /// </remarks> 
     571        public OrderedDictionary<DataKey, object> GetValues(string dataField) 
     572        { 
     573            EnsureDataKeys(); 
     574 
     575            IList<BoundFieldAccessor> boundFieldAccessors = GetBoundFieldAccessors(dataField); 
     576            if (boundFieldAccessors == null) 
     577            { 
     578                return null; 
     579            } 
     580 
     581            GridViewRowCollection rows = Rows; 
     582            DataKeyArray allKeys = DataKeys; 
     583 
     584            OrderedDictionary<DataKey, object> dictionary = new OrderedDictionary<DataKey, object>(rows.Count); 
     585 
     586            foreach (GridViewRow row in rows) 
     587            { 
     588                // データ行以外は無視 
     589                if (row.RowType != DataControlRowType.DataRow) 
     590                { 
     591                    continue; 
     592                } 
     593 
     594                DataKey dataKey = allKeys[row.RowIndex]; 
     595                if (dataKey == null) 
     596                { 
     597                    continue; 
     598                } 
     599 
     600                // ExtractValuesFromCell メソッドを使用してフィールドの値を収集 (フィールドが複数ある場合は後勝ち) 
     601                OrderedDictionary cellValueDictionary = new OrderedDictionary(); 
     602                foreach (BoundFieldAccessor boundFieldAccessor in boundFieldAccessors) 
     603                { 
     604                    DataControlFieldCell cell = (DataControlFieldCell)row.Cells[boundFieldAccessor.ColumnIndex]; 
     605                    boundFieldAccessor.BoundField.ExtractValuesFromCell(cellValueDictionary, cell, DataControlRowState.Normal, true); 
     606                } 
     607 
     608                dictionary.Add( 
     609                    dataKey, 
     610                    cellValueDictionary.Contains(dataField) ? cellValueDictionary[dataField] : null); 
     611            } 
     612 
     613            return dictionary; 
     614        } 
     615 
     616        /// <summary> 
    546617        /// <see cref="BaseDataBoundControl.DataSourceID"/> 
    547618        /// プロパティが設定されていて、データ バインド コントロールにバインディングが必要とマークされている場合に、 
     
    568639            if (selectedValues != null) 
    569640            { 
     641                EnsureDataKeys(); 
    570642                UpdateSelectFieldState(); 
    571643                selectedValues = null; 
     
    9301002 
    9311003        /// <summary> 
     1004        /// 指定したデータフィールド名に対応する 
     1005        /// <see cref="BoundFieldAccessor"/> の一覧を返します。 
     1006        /// </summary> 
     1007        /// <param name="dataField">データフィールドの名前。</param> 
     1008        /// <returns> 
     1009        /// <see cref="BoundFieldAccessor"/> の一覧。 
     1010        /// 見付からない場合は <see langword="null"/>。 
     1011        /// </returns> 
     1012        private IList<BoundFieldAccessor> GetBoundFieldAccessors(string dataField) 
     1013        { 
     1014            List<BoundFieldAccessor> indexes = new List<BoundFieldAccessor>(); 
     1015 
     1016            DataControlFieldCollection columns = Columns; 
     1017            for (int i = 0; i < columns.Count; i++) 
     1018            { 
     1019                System.Web.UI.WebControls.BoundField boundField = columns[i] as System.Web.UI.WebControls.BoundField; 
     1020                if (boundField != null && Equals(boundField.DataField, dataField)) 
     1021                { 
     1022                    indexes.Add(new BoundFieldAccessor(i, boundField)); 
     1023                } 
     1024            } 
     1025 
     1026            return indexes.Count > 0 ? indexes : null; 
     1027        } 
     1028 
     1029        /// <summary> 
    9321030        /// データキーの最初のフィールドを検査し、全ての最初のフィールドの値を格納可能な型を返します。 
    9331031        /// </summary> 
     
    10521150            } 
    10531151        } 
     1152 
     1153        /// <summary> 
     1154        /// <see cref="System.Web.UI.WebControls.GridView.DataKeys"/> が使えるかチェックします。 
     1155        /// </summary> 
     1156        private void EnsureDataKeys() 
     1157        { 
     1158            if (DataKeyNames.Length == 0) 
     1159            { 
     1160                throw new InvalidOperationException( 
     1161                    string.Format( 
     1162                        CultureInfo.CurrentCulture, 
     1163                        Resources.InvalidOperation_GridView_DataKeyNamesMustBeSpecified, 
     1164                        ID)); 
     1165            } 
     1166        } 
     1167 
     1168 
     1169        /// <summary> 
     1170        /// バウンドフィールドにアクセスするためのクラスです。 
     1171        /// </summary> 
     1172        [DebuggerDisplay(@"\{ColumnIdex = {columnIndex} DataField = {boundField.DataField}\}")] 
     1173        private sealed class BoundFieldAccessor 
     1174        { 
     1175            /// <summary> 
     1176            /// カラムのインデックス番号。 
     1177            /// </summary> 
     1178            [DebuggerBrowsable(DebuggerBrowsableState.Never)] 
     1179            private readonly int columnIndex; 
     1180 
     1181            /// <summary> 
     1182            /// <see cref="System.Web.UI.WebControls.BoundField"/>。 
     1183            /// </summary> 
     1184            [DebuggerBrowsable(DebuggerBrowsableState.Never)] 
     1185            private readonly System.Web.UI.WebControls.BoundField boundField; 
     1186 
     1187 
     1188            /// <summary> 
     1189            /// インスタンスを作成します。 
     1190            /// </summary> 
     1191            /// <param name="columnIndex">カラムのインデックス番号。</param> 
     1192            /// <param name="boundField"><see cref="System.Web.UI.WebControls.BoundField"/>。</param> 
     1193            internal BoundFieldAccessor(int columnIndex, System.Web.UI.WebControls.BoundField boundField) 
     1194            { 
     1195                this.columnIndex = columnIndex; 
     1196                this.boundField = boundField; 
     1197            } 
     1198 
     1199            /// <summary> 
     1200            /// カラムのインデックス番号を取得します。 
     1201            /// </summary> 
     1202            /// <value> 
     1203            /// カラムのインデックス番号。 
     1204            /// </value> 
     1205            internal int ColumnIndex 
     1206            { 
     1207                get 
     1208                { 
     1209                    return columnIndex; 
     1210                } 
     1211            } 
     1212 
     1213            /// <summary> 
     1214            /// <see cref="System.Web.UI.WebControls.BoundField"/> を取得します。 
     1215            /// </summary> 
     1216            /// <value> 
     1217            /// <see cref="System.Web.UI.WebControls.BoundField"/>。 
     1218            /// </value> 
     1219            internal System.Web.UI.WebControls.BoundField BoundField 
     1220            { 
     1221                get 
     1222                { 
     1223                    return boundField; 
     1224                } 
     1225            } 
     1226        } 
    10541227    } 
    10551228} 
  • framework/trunk/WebLibrary/Sources/UI/WebControls/RadioButton.cs

    r1348 r1633  
    5757        private const string ForceRenderLabelKey = "ForceRenderLabel"; 
    5858 
     59        /// <summary> 
     60        /// <see cref="InnerValue"/> プロパティ用のキー。 
     61        /// </summary> 
     62        private const string InnerValueKey = "InnerValue"; 
     63 
    5964        // AgentSmith SpellCheck Disable 
    6065 
     
    142147        } 
    143148 
     149        /// <summary> 
     150        /// 内部の値を取得または設定します。 
     151        /// </summary> 
     152        /// <value> 
     153        /// 内部の値。 
     154        /// </value> 
     155        internal object InnerValue 
     156        { 
     157            get 
     158            { 
     159                return ViewState[InnerValueKey]; 
     160            } 
     161 
     162            set 
     163            { 
     164                ViewState[InnerValueKey] = value; 
     165            } 
     166        } 
     167 
    144168 
    145169        /// <summary> 
  • framework/trunk/WebLibrary/WebLibrary.csproj

    r1619 r1633  
    166166    <Compile Include="Sources\UI\WebControls\NumericBox.cs" /> 
    167167    <Compile Include="Sources\UI\WebControls\ObjectDataSource.cs" /> 
     168    <Compile Include="Sources\UI\WebControls\RadioButtonField.cs" /> 
    168169    <Compile Include="Sources\UI\WebControls\Reloader.cs" /> 
    169170    <Compile Include="Sources\UI\WebControls\DialogOpenButton.cs" /> 
詳しい使い方は TracChangeset を参照してください。