Parameter.DefaultValue Property
Assembly: System.Web (in system.web.dll)
/** @property */ public String get_DefaultValue () /** @property */ public void set_DefaultValue (String value)
public function get DefaultValue () : String public function set DefaultValue (value : String)
Not applicable.
Property Value
A string that serves as a default value for the Parameter when the value it is bound to cannot be resolved or is uninitialized.The DefaultValue property is used in scenarios where the parameter is bound to a value, but the value is a null reference (Nothing in Visual Basic) or cannot be resolved when the Parameter object is evaluated.
If the DefaultValue property of the parameter is changed, the OnParameterChanged method is called.
The following code example demonstrates how to retrieve a single data record using an ObjectDataSource control and display it in a DetailsView control. The ObjectDataSource control retrieves a specific employee record by calling the GetEmployee method of the EmployeeLogic class. The GetEmployee method requires an employee ID parameter. The ObjectDataSource control uses a QueryStringParameter object in its SelectParameters collection to pass an ID to the GetEmployee method in this example.
To view the example implementation of the EmployeeLogic class and the GetEmployee method, see the ObjectDataSource class overview.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.jsl" Assembly="Samples.AspNet.jsl" %>
<%@ Page Language="VJ#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ObjectDataSource - VJ# Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:detailsview
id="DetailsView1"
runat="server"
datasourceid="ObjectDataSource1">
</asp:detailsview>
<asp:objectdatasource
id="ObjectDataSource1"
runat="server"
selectmethod="GetEmployee"
typename="Samples.AspNet.jsl.EmployeeLogic" >
<selectparameters>
<asp:querystringparameter name="anID" querystringfield="empid" defaultvalue="-1" />
</selectparameters>
</asp:objectdatasource>
</form>
</body>
</html>