ToString Method

Parameter.ToString Method ()


Converts the value of this instance to its equivalent string representation.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

Public Overrides Function ToString As String

Return Value

Type: System.String

A string representation of the value of this instance.

The ToString method returns the Name property of the Parameter object. If the Parameter object has no name, ToString returns String.Empty.

The following code example demonstrates how to access various properties of a Parameter object, including its Name and Type properties.

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

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

    Dim sqlSource As New SqlDataSource
    sqlSource.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 />")


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


 End Sub 'Page_Load

<html xmlns="" >
    <head runat="server">
    <title>ASP.NET Example</title>
        <form id="form1" runat="server">

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


.NET Framework
Available since 2.0
Return to top
© 2016 Microsoft