Parameter.ToString Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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


.NET Framework
Available since 2.0
Return to top