本文整理汇总了VB.NET中System.Web.UI.WebControls.Parameter类的典型用法代码示例。如果您正苦于以下问题:VB.NET Parameter类的具体用法?VB.NET Parameter怎么用?VB.NET Parameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parameter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: SqlDataSource
Partial Class param1avb_aspx
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim sqlSource As SqlDataSource
sqlSource = New SqlDataSource(ConfigurationManager.ConnectionStrings("MyNorthwind").ConnectionString, "SELECT FirstName, LastName FROM Employees WHERE Country = @country;")
Dim country As New ControlParameter()
country.Name = "country"
country.Type = TypeCode.String
country.ControlID = "DropDownList1"
country.PropertyName = "SelectedValue"
' If the DefaultValue is not set, the DataGrid does not
' display anything on the first page load. This is because
' on the first page load, the DropDownList has no
' selected item, and the ControlParameter evaluates to
' String.Empty.
country.DefaultValue = "USA"
sqlSource.SelectParameters.Add(country)
' Add the SqlDataSource to the page controls collection.
Page.Controls.Add(sqlSource)
DataGrid1.DataSource = sqlSource
DataGrid1.DataBind()
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System.Web.UI.WebControls,代码行数:29,代码来源:Parameter
示例2: StaticParameter
' 导入命名空间
Imports System.ComponentModel
Imports System.Security.Permissions
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace Samples.AspNet
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class StaticParameter
Inherits Parameter
Public Sub New()
End Sub
' The StaticParameter(string, object) constructor
' initializes the DataValue property and calls the
' Parameter(string) constructor to initialize the Name property.
Public Sub New(name As String, value As Object)
MyBase.New(name)
DataValue = value
End Sub
' The StaticParameter(string, TypeCode, object) constructor
' initializes the DataValue property and calls the
' Parameter(string, TypeCode) constructor to initialize the Name and
' Type properties.
Public Sub New(name As String, type As TypeCode, value As Object)
MyBase.New(name, type)
DataValue = value
End Sub
' The StaticParameter copy constructor is provided to ensure that
' the state contained in the DataValue property is copied to new
' instances of the class.
Protected Sub New(original As StaticParameter)
MyBase.New(original)
DataValue = original.DataValue
End Sub
' The Clone method is overridden to call the
' StaticParameter copy constructor, so that the data in
' the DataValue property is correctly transferred to the
' new instance of the StaticParameter.
Protected Overrides Function Clone() As Parameter
Return New StaticParameter(Me)
End Function
' The DataValue can be any arbitrary object and is stored in ViewState.
Public Property DataValue() As Object
Get
Return ViewState("Value")
End Get
Set
ViewState("Value") = value
End Set
End Property
' The Value property is a type safe convenience property
' used when the StaticParameter represents string data.
' It gets the string value of the DataValue property, and
' sets the DataValue property directly.
Public Property Value() As String
Get
Dim o As Object = DataValue
If o Is Nothing OrElse Not TypeOf o Is String Then
Return String.Empty
End If
Return CStr(o)
End Get
Set
DataValue = value
OnParameterChanged()
End Set
End Property
' The Evaluate method is overridden to return the
' DataValue property instead of the DefaultValue.
Protected Overrides Function Evaluate(context As HttpContext, control As Control) As Object
If context Is Nothing Then
Return Nothing
Else
Return DataValue
End If
End Function
End Class
End Namespace ' Samples.AspNet
开发者ID:VB.NET开发者,项目名称:System.Web.UI.WebControls,代码行数:87,代码来源:Parameter
注:本文中的System.Web.UI.WebControls.Parameter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论