This documentation is archived and is not being maintained.

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 override string ToString()

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="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<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 />");


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


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

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


Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0