BoundField.ReadOnly プロパティ
アセンブリ: System.Web (system.web.dll 内)

/** @property */ public boolean get_ReadOnly () /** @property */ public void set_ReadOnly (boolean value)
編集モードでフィールド値を変更できないようにする場合は true。それ以外の場合は false。既定値は false です。

BoundField オブジェクトに表示される値を変更できないようにするには、ReadOnly プロパティを使用します。データ バインド コントロールが編集モードである場合、読み取り専用フィールドは編集コントロールのないプレーンテキストとして表示されます。
![]() |
---|
ReadOnly プロパティは編集モードだけに適用されます。フィールドが挿入モードとして表示されないようにするには、InsertVisible プロパティを使用します。 |

ReadOnly プロパティを使用して、BoundField オブジェクトに表示するキー フィールドの値を編集モードで変更できないようにするコード例を次に示します。
<%@ Page language="VB" %> <html> <body> <form runat="server"> <h3>BoundField Example</h3> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" autogenerateeditbutton="true" allowpaging="true" datakeynames="CustomerID" runat="server"> <columns> <asp:boundfield datafield="CustomerID" readonly="true" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" convertemptystringtonull="true" headertext="Customer Name"/> <asp:boundfield datafield="Address" convertemptystringtonull="true" headertext="Address"/> <asp:boundfield datafield="City" convertemptystringtonull="true" headertext="City"/> <asp:boundfield datafield="PostalCode" convertemptystringtonull="true" headertext="ZIP Code"/> <asp:boundfield datafield="Country" convertemptystringtonull="true" headertext="Country"/> </columns> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" updatecommand="Update Customers Set CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country Where (CustomerID = @CustomerID)" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </asp:sqldatasource> </form> </body> </html>
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>BoundField Example</h3> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" autogenerateeditbutton="true" allowpaging="true" datakeynames="CustomerID" runat="server"> <columns> <asp:boundfield datafield="CustomerID" readonly="true" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" convertemptystringtonull="true" headertext="Customer Name"/> <asp:boundfield datafield="Address" convertemptystringtonull="true" headertext="Address"/> <asp:boundfield datafield="City" convertemptystringtonull="true" headertext="City"/> <asp:boundfield datafield="PostalCode" convertemptystringtonull="true" headertext="ZIP Code"/> <asp:boundfield datafield="Country" convertemptystringtonull="true" headertext="Country"/> </columns> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" updatecommand="Update Customers Set CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country Where (CustomerID = @CustomerID)" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </asp:sqldatasource> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からBoundField.ReadOnly プロパティを検索する場合は、下記のリンクをクリックしてください。

- BoundField.ReadOnly プロパティのページへのリンク