Parameter.ToString メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Parameter.ToString メソッドの意味・解説 

Parameter.ToString メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

このインスタンスの値を、それと等価文字列形式変換します

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

解説解説
使用例使用例

Name プロパティType プロパティなど、Parameter オブジェクトさまざまなプロパティアクセスする方法次のコード例示します

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
 Sub Page_Load(ByVal sender As
 Object, ByVal e As EventArgs)

    Dim sqlSource As New
 SqlDataSource
    sqlSource.ConnectionString = _
        ConfigurationManager.ConnectionStrings("MyNorthwind").ConnectionString

    sqlSource.SelectCommand = _
        "SELECT * From Employees where EmployeeID = @employee"


    ' When a Parameter is not named, Name returns String.Empty.
    Dim userID As New Parameter()

    If userID.Name Is String.Empty
 Then
        Response.Write("Name is Empty<BR>")
    End If

    If userID.Name Is Nothing
 Then
        Response.Write("Name is Null<BR>")
    End If

    ' Set the Name of the Parameter
    userID.Name = "employee"

    ' The Parameter.DefaultValue property is used to bind a static String
    userID.DefaultValue = "3"

    ' The ToString method returns the Name of the Parameter
    Response.Write(userID.ToString & "<BR>")
    Response.Write(userID.Name & "<BR>")

    ' The default Type of the Parameter is TypeCode.Object
    Response.Write(userID.Type.ToString & "<BR>")

    sqlSource.SelectParameters.Add(userID)
    Page.Controls.Add(sqlSource)

    Dim grid As New GridView()
    grid.DataSource = sqlSource
    grid.DataBind()

    PlaceHolder1.Controls.Add(grid)

 End Sub 'Page_Load
</SCRIPT>

<HTML>
    <BODY>
        <FORM runat="server">

       <asp:PlaceHolder id="PlaceHolder1" runat="server"/>

        </FORM>
    </BODY>
</HTML>
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
 private void Page_Load(object sender, EventArgs
 e) {

    SqlDataSource sqlSource = 
        new SqlDataSource(ConfigurationManager.ConnectionStrings["MyNorthwind"].ConnectionString
,
                          "SELECT * From Employees where EmployeeID = @employee");
    
    // When a Parameter is not named, Name returns String.Empty.
    Parameter userID = new Parameter();

    if (userID.Name.Equals(String.Empty)) {
        Response.Write("Name is Empty<BR>");
    }

    if (null == userID.Name) {
        Response.Write("Name is Null<BR>");
    }

    // Set the Name of the Parameter
    userID.Name = "employee";

    // The Parameter.DefaultValue property is used to bind a static
 String.
    userID.DefaultValue = "3";

    // The ToString method returns the Name of the Parameter.
    Response.Write(userID.ToString() + "<BR>");
    Response.Write(userID.Name + "<BR>");

    // The default Type of the Parameter is TypeCode.Object
    Response.Write(userID.Type.ToString() + "<BR>");

    sqlSource.SelectParameters.Add(userID);
    Page.Controls.Add(sqlSource);

    GridView grid = new GridView();
    grid.DataSource = sqlSource;
    grid.DataBind();

    PlaceHolder1.Controls.Add(grid);
}
</SCRIPT>

<HTML>
    <BODY>
        <FORM runat="server">

       <asp:PlaceHolder id="PlaceHolder1" runat="server"/>

        </FORM>
    </BODY>
</HTML>
<%@ Page Language="VJ#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
 private void Page_Load(Object sender, System.EventArgs
 e)
 {
    SqlDataSource sqlSource = new SqlDataSource("Data Source=localhost;"
 
        + "Integrated Security=SSPI;Initial Catalog=Northwind;", "SELECT
 * " 
        + "From Employees where EmployeeID = @employee");
    
    // When a Parameter is not named, Name returns String.Empty.
    Parameter userID = new Parameter();

    if (userID.get_Name().Equals("")) {
        get_Response().Write("Name is Empty<BR>");
    }

    if (null == userID.get_Name()) {
        get_Response().Write("Name is Null<BR>");
    }

    // Set the Name of the Parameter
    userID.set_Name("employee");

    // The Parameter.DefaultValue property is used to bind a static
 String.
    userID.set_DefaultValue("3");

    // The ToString method returns the Name of the Parameter.
    get_Response().Write(userID.ToString() + "<BR>");
    get_Response().Write(userID.get_Name() + "<BR>");

    // The default Type of the Parameter is TypeCode.Object
    get_Response().Write(userID.get_Type().ToString() + "<BR>");

    sqlSource.get_SelectParameters().Add(userID);
    get_Page().get_Controls().Add(sqlSource);

    GridView grid = new GridView();
    grid.set_DataSource(sqlSource);
    grid.DataBind();
        
    PlaceHolder1.get_Controls().Add(grid);
} //Page_Load

</SCRIPT>

<HTML>
    <BODY>
        <FORM runat="server">

       <asp:PlaceHolder id="PlaceHolder1" runat="server"/>

        </FORM>
    </BODY>
</HTML>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からParameter.ToString メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からParameter.ToString メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からParameter.ToString メソッド を検索

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

辞書ショートカット

すべての辞書の索引

Parameter.ToString メソッドのお隣キーワード
検索ランキング

   

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



Parameter.ToString メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS