GridViewRow.RowState プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > GridViewRow.RowState プロパティの意味・解説 

GridViewRow.RowState プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

GridViewRow オブジェクトの状態を取得します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Overridable Property
 RowState As DataControlRowState
Dim instance As GridViewRow
Dim value As DataControlRowState

value = instance.RowState

instance.RowState = value
public virtual DataControlRowState RowState { get;
 set; }
public:
virtual property DataControlRowState RowState {
    DataControlRowState get ();
    void set (DataControlRowState value);
}
/** @property */
public DataControlRowState get_RowState ()

/** @property */
public void set_RowState (DataControlRowState
 value)
public function get RowState
 () : DataControlRowState

public function set RowState
 (value : DataControlRowState)

プロパティ
DataControlRowState 値のビットごとの組み合わせ

解説解説

RowType プロパティ使用してGridViewRow オブジェクトの状態を確認します。状態は、次の表に示す値のビットごとの組み合わせなります

状態の値

説明

DataControlRowState.Alternate

GridViewRow オブジェクトは、GridView コントロール交互の行です。

DataControlRowState.Edit

GridViewRow オブジェクト編集モードです。

DataControlRowState.Normal

GridViewRow オブジェクト標準 (既定) の状態です。

DataControlRowState.Selected

GridViewRow オブジェクト選択されています。

このプロパティは、通常操作実行前に行の状態を確認するために使用されます。

使用例使用例

RowState プロパティ使用して、行が編集モードであるかどうか、または選択されているかどうか確認する方法次の例に示しますGridView コントロール編集モードのときにユーザー別の行を選択すると、GridView コントロール編集モード終了します

<%@ Page language="VB" %>

<script runat="server">
  
  Sub AuthorsGridView_SelectedIndexChanged(ByVal
 sender As Object, ByVal
 e As EventArgs)
  
    ' Get the selected row.
    Dim row As GridViewRow = AuthorsGridView.SelectedRow
    
    ' Check the row state. If the row is not in edit mode and is selected
,
    ' exit edit mode. This ensures that the GridView control exits edit
 mode
    ' when a user selects a different row while the GridView control
 is in 
    ' edit mode. Notice that the DataControlRowState enumeration is
 a flag
    ' enumeration, which means that you can combine values using bitwise
    ' operations.
    If row.RowState <> (DataControlRowState.Edit Or
 DataControlRowState.Selected) Then

      AuthorsGridView.EditIndex = -1
    
    End If
          
  End Sub
  
  Sub AuthorsGridView_RowEditing(ByVal sender
 As Object, ByVal e As
 GridViewEditEventArgs)
    
    ' Get the row being edited.
    Dim row As GridViewRow = AuthorsGridView.Rows(e.NewEditIndex)
    
    ' Check the row state. If the row is not in edit mode and is selected
,
    ' select the current row. This ensures that the GridView control
 selects
    ' the current row when the user clicks the Edit button.
    If row.RowState <> (DataControlRowState.Edit Or
 DataControlRowState.Selected) Then
    
      AuthorsGridView.SelectedIndex = e.NewEditIndex
    
    End If
    
  End Sub

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>GridViewRow RowState Example</h3>

      <!-- The GridView control automatically sets the columns     -->
      <!-- specified in the datakeynames attribute as
 read-only    -->
      <!-- No input controls are rendered for these columns
 in     -->
      <!-- edit mode.                                              -->
      <asp:gridview id="AuthorsGridView" 
        datasourceid="AuthorsSqlDataSource" 
        autogeneratecolumns="false"
        autogenerateeditbutton="true"
        autogenerateselectbutton="true" 
        datakeynames="au_id"
        cellpadding="10"
        onselectedindexchanged="AuthorsGridView_SelectedIndexChanged"
        onrowediting="AuthorsGridView_RowEditing"
       
        runat="server">
        
        <selectedrowstyle backcolor="Yellow"/>
               
        <columns>
        
          <asp:boundfield datafield="au_lname"
            headertext="Last Name"/>
          <asp:boundfield datafield="au_fname"
            headertext="First Name"/> 
        
        </columns>
             
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects
 -->
      <!-- to the Pubs sample database.                   
     -->
      <asp:sqldatasource id="AuthorsSqlDataSource"
  
        selectcommand="SELECT [au_id], [au_lname], [au_fname]
 FROM [authors]"             
        updatecommand="UPDATE authors SET au_lname=@au_lname,
 au_fname=@au_fname WHERE (authors.au_id = @au_id)" 
        connectionstring="server=localhost;database=pubs;integrated
 security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

<%@ Page language="C#" %>

<script runat="server">
  
  void AuthorsGridView_SelectedIndexChanged(Object sender, EventArgs
 e)
  {
  
    // Get the selected row.
    GridViewRow row = AuthorsGridView.SelectedRow;
    
    // Check the row state. If the row is not in edit mode and is selected
,
    // exit edit mode. This ensures that the GridView control exits
 edit mode
    // when a user selects a different row while the GridView control
 is in 
    // edit mode. Notice that the DataControlRowState enumeration is
 a flag
    // enumeration, which means that you can combine values using bitwise
    // operations.
    if(row.RowState != (DataControlRowState.Edit|DataControlRowState.Selected))
    {
      AuthorsGridView.EditIndex = -1;
    } 
          
  }
  
  void AuthorsGridView_RowEditing(Object sender, GridViewEditEventArgs
 e)
  {
    
    // Get the row being edited.
    GridViewRow row = AuthorsGridView.Rows[e.NewEditIndex];
    
    // Check the row state. If the row is not in edit mode and is selected
,
    // select the current row. This ensures that the GridView control
 selects
    // the current row when the user clicks the Edit button.
    if(row.RowState != (DataControlRowState.Edit|DataControlRowState.Selected))
    {
      AuthorsGridView.SelectedIndex = e.NewEditIndex;
    }
    
  } 

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>GridViewRow RowState Example</h3>

      <!-- The GridView control automatically sets the columns     -->
      <!-- specified in the datakeynames attribute as read-only
    -->
      <!-- No input controls are rendered for these columns
 in     -->
      <!-- edit mode.                                              -->
      <asp:gridview id="AuthorsGridView" 
        datasourceid="AuthorsSqlDataSource" 
        autogeneratecolumns="false"
        autogenerateeditbutton="true"
        autogenerateselectbutton="true" 
        datakeynames="au_id"
        cellpadding="10"
        onselectedindexchanged="AuthorsGridView_SelectedIndexChanged"
        onrowediting="AuthorsGridView_RowEditing"       
        runat="server">
        
        <selectedrowstyle backcolor="Yellow"/>
               
        <columns>
        
          <asp:boundfield datafield="au_lname"
            headertext="Last Name"/>
          <asp:boundfield datafield="au_fname"
            headertext="First Name"/> 
        
        </columns>
             
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Pubs sample database.                        -->
      <asp:sqldatasource id="AuthorsSqlDataSource"  
        selectcommand="SELECT [au_id], [au_lname], [au_fname] FROM [authors]"
             
        updatecommand="UPDATE authors SET au_lname=@au_lname, au_fname=@au_fname
 WHERE (authors.au_id = @au_id)" 
        connectionstring="server=localhost;database=pubs;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GridViewRow クラス
GridViewRow メンバ
System.Web.UI.WebControls 名前空間
DataControlRowState 列挙
DataControlRowType 列挙
RowType



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「GridViewRow.RowState プロパティ」の関連用語

GridViewRow.RowState プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



GridViewRow.RowState プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS