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

Dim instance As CommandField Dim value As Boolean value = instance.ShowSelectButton instance.ShowSelectButton = value
/** @property */ public boolean get_ShowSelectButton () /** @property */ public void set_ShowSelectButton (boolean value)
public function get ShowSelectButton () : boolean public function set ShowSelectButton (value : boolean)
CommandField に Select ボタンを表示する場合は true。それ以外の場合は false。既定値は false です。

ShowSelectButton プロパティを使用して、データ ソース コントロール内のそれぞれのレコードの CommandField フィールドに Select ボタンを表示するかどうかを指定します。Select ボタンを使用すると、ユーザーはデータ ソース コントロール内の行を選択できます。レコードの Select ボタンをクリックすると、データ ソース コントロールがそれに応答します。たとえば、GridView コントロールは、SelectedDataKey、SelectedIndex、SelectedRow、および SelectedValue の各プロパティを、選択した行に対応する値に更新します。選択した行に SelectedRowStyle スタイルが適用され、SelectedIndexChanged イベントおよび SelectedIndexChanging イベントが発生します。
CommandField フィールドの ButtonType プロパティが ButtonType.Button または ButtonType.Link に設定されている場合は、SelectText プロパティを使用して、Select ボタンに表示するテキストを指定します。または、最初に ButtonType プロパティを ButtonType.Image に設定してから SelectImageUrl プロパティを設定することにより、イメージを表示できます。

ShowSelectButton プロパティを使用して、GridView コントロール内のそれぞれのレコードに Select ボタンを表示する方法を次のコード例に示します。
<%@ Page language="VB" %> <script runat="server"> Sub CustomersGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CustomersGridView.SelectedIndexChanged ' Retrieve the company name from the appropriate cell. Dim companyName As String = CustomersGridView.SelectedRow.Cells(2).Text ' Display company name selected by the user. Message.Text = "You selected " & companyName & "." End Sub </script> <html> <body> <form runat="server"> <h3>CommandField Example</h3> <asp:Label id="Message" forecolor="Red" runat="server"/> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" datakeynames="CustomerID" runat="server"> <columns> <asp:commandfield showselectbutton="true" headertext="Select Customer"/> <asp:boundfield datafield="CustomerID" headertext="Customer ID" /> <asp:boundfield datafield="CompanyName" headertext="Company Name"/> <asp:boundfield datafield="Address" headertext="Address"/> <asp:boundfield datafield="City" headertext="City"/> <asp:boundfield datafield="PostalCode" headertext="ZIP Code"/> <asp:boundfield datafield="Country" 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]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </asp:sqldatasource> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void CustomersGridView_SelectedIndexChanged(Object sender, EventArgs e) { // Retrieve the company name from the appropriate cell. String companyName = CustomersGridView.SelectedRow.Cells[2].Text; // Display company name selected by the user. Message.Text = "You selected " + companyName + "."; } </script> <html> <body> <form runat="server"> <h3>CommandField Example</h3> <asp:Label id="Message" forecolor="Red" runat="server"/> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="false" datakeynames="CustomerID" onselectedindexchanged="CustomersGridView_SelectedIndexChanged" runat="server"> <columns> <asp:commandfield showselectbutton="true" headertext="Select Customer"/> <asp:boundfield datafield="CustomerID" headertext="Customer ID" /> <asp:boundfield datafield="CompanyName" headertext="Company Name"/> <asp:boundfield datafield="Address" headertext="Address"/> <asp:boundfield datafield="City" headertext="City"/> <asp:boundfield datafield="PostalCode" headertext="ZIP Code"/> <asp:boundfield datafield="Country" 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]" 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に収録されているすべての辞書からCommandField.ShowSelectButton プロパティを検索する場合は、下記のリンクをクリックしてください。

- CommandField.ShowSelectButton プロパティのページへのリンク