日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

select html value属性,HtmlSelect.DataValueField 属性 (System.Web.UI.HtmlControls) | Microsoft Docs...

發布時間:2024/10/8 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 select html value属性,HtmlSelect.DataValueField 属性 (System.Web.UI.HtmlControls) | Microsoft Docs... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

獲取或設置數據源中要綁定到 Value 控件中各項的 HtmlSelect 屬性的字段。Gets or sets the field from the data source to bind to the Value property of each item in the HtmlSelect control.

public:

virtual property System::String ^ DataValueField { System::String ^ get(); void set(System::String ^ value); };

public virtual string DataValueField { get; set; }

member this.DataValueField : string with get, set

Public Overridable Property DataValueField As String

屬性值

數據源中要綁定到 Value 控件中各項的 HtmlSelect 屬性的字段。The field from the data source to bind to the Value property of each item in the HtmlSelect control. 默認值為空字符串 (""),指示尚未設置該屬性。The default value is an empty string (""), which indicates that the property has not been set.

示例

The following code example demonstrates how to use the DataSource and DataValueField properties to specify the field from the data source to bind to the ListItem.Value property of each item in the HtmlSelect control.

/p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

HtmlSelect Example

void Page_Load (Object sender, EventArgs e)

{

// Bind the HtmlSelect control to a data source when the page is initially loaded.

if (!IsPostBack)

{

// Open a connection to the database and run the query.

// Note that the connection string may vary depending on your

// database server settings.

string ConnectString = "server=localhost;database=pubs;integrated security=SSPI";

string QueryString = "select * from authors";

SqlConnection myConnection = new SqlConnection(ConnectString);

SqlDataAdapter myCommand = new SqlDataAdapter(QueryString, myConnection);

// Create a dataset to store the query results.

DataSet ds = new DataSet();

myCommand.Fill(ds, "Authors");

// Bind the HtmlSelect control to the data source.

Select1.DataSource = ds;

Select1.DataTextField = "au_fname";

Select1.DataValueField = "au_fname";

Select1.DataBind();

}

}

void Button_Click (Object sender, EventArgs e)

{

// Display the selected items.

Label1.Text = "You selected:";

for (int i=0; i<=Select1.Items.Count - 1; i++)

{

if (Select1.Items[i].Selected)

Label1.Text += "
?? - " + Select1.Items[i].Text;

}

}

HtmlSelect Example

Select items from the list.

Use the Control or Shift key to select multiple items.

multiple="true"

runat="server"/>

onserverclick="Button_Click"

runat="server">

Submit

runat="server"/>

/p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

HtmlSelect Example

Sub Page_Load (sender As Object, e As EventArgs)

' Bind the HtmlSelect control to a data source when the page is initially loaded.

If Not IsPostBack Then

' Open a connection to the database and run the query.

' Note that the connection string may vary depending on your

' database server settings.

Dim ConnectString As String = "server=localhost;database=pubs;integrated security=SSPI"

Dim QueryString As String = "select * from authors"

Dim myConnection As SqlConnection = New SqlConnection(ConnectString)

Dim myCommand As SqlDataAdapter = New SqlDataAdapter(QueryString, myConnection)

' Create a dataset to store the query results.

Dim ds As DataSet = New DataSet()

myCommand.Fill(ds, "Authors")

' Bind the HtmlSelect control to the data source.

Select1.DataSource = ds

Select1.DataTextField = "au_fname"

Select1.DataValueField = "au_fname"

Select1.DataBind()

End If

End Sub

Sub Button_Click (sender As Object, e As EventArgs)

Dim i As Integer

Label1.Text = "You selected:"

For i = 0 To Select1.Items.Count - 1

If Select1.Items(i).Selected Then

Label1.Text = Label1.Text & "
?? - " & Select1.Items(i).Text

End If

Next i

End Sub

HtmlSelect Example

Select items from the list.

Use the Control or Shift key to select multiple items.

multiple="true"

runat="server"/>

onserverclick="Button_Click"

runat="server">

Submit

runat="server"/>

The following code example demonstrates how to use the DataSourceID and DataValueField properties to specify the field from the data source to bind to the ListItem.Value property of each item in the HtmlSelect control.

/p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

void SubmitButton_Click (object sender, System.EventArgs e)

{

// Iterate through the list items in the

// HtmlSelect control to find the selected item.

for (int i = 0; i <= Select1.Items.Count - 1; i++)

{

if (Select1.Items[i].Selected)

// Display the Value property of the selected item.

// This property is populated by the DataValueField property.

Label1.Text = "The Product ID is " + Select1.Items[i].Value;

}

}

HtmlSelect.DataValueField

HtmlSelect.DataValueField Example 2

Select an item from the list:

name="Select1"

datasourceid="SqlDataSource1"

datatextfield="ProductName"

datavaluefield="ProductID"

runat="server">

connectionstring="workstation id=localhost;integrated security=SSPI;initial catalog=Northwind"

selectcommand="SELECT * FROM [Products] Where ProductID <= 5"

runat="server">

text="Submit"

οnclick="SubmitButton_Click"

runat="Server">

runat="Server">

/p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Dim i As Integer

' Iterate through the list items in the

' HtmlSelect control to find the selected item.

For i = 0 To Select1.Items.Count - 1

If Select1.Items(i).Selected Then

' Display the Value property of the selected item.

' This property is populated by the DataValueField property.

Label1.Text = "The Product ID is " & Select1.Items(i).Value

End If

Next i

End Sub

HtmlSelect.DataValueField

HtmlSelect.DataValueField Example 2

Select an item from the list:

name="Select1"

datasourceid="SqlDataSource1"

datatextfield="ProductName"

datavaluefield="ProductID"

runat="server">

connectionstring="workstation id=localhost;integrated security=SSPI;initial catalog=Northwind"

selectcommand="SELECT * FROM [Products] Where ProductID <= 5"

runat="server">

text="Submit"

οnclick="SubmitButton_Click"

runat="Server">

runat="Server">

注解

使用 DataValueField 屬性可指定數據源中要綁定到 ListItem.Value 控件中每個項的屬性的字段。Use the DataValueField property to specify which field from the data source to bind to the ListItem.Value property of each item in the control. This property is commonly used to provide a value for the ListItem.Value property that differs from the value of the ListItem.Text property.

HtmlSelect類提供兩個屬性,用于指定要綁定到的數據源。The HtmlSelect class provides two properties for specifying the data source to bind to. 使用 DataSource 屬性指定數據源時,必須顯式調用 DataBind 方法,將控件及其 DataValueField 屬性綁定到數據源。When you use the DataSource property to specify the data source, you must explicitly call the DataBind method to bind the control and its DataValueField property to the data source.

DataSourceID屬性允許您將 HtmlSelect 控件綁定到表示數據源的數據源控件。The DataSourceID property allows you to bind an HtmlSelect control to a data source control that represents a data source. When you use the DataSourceID property to specify the data source, the HtmlSelect control and its DataValueField property automatically bind to the data source control. 因此,無需顯式調用 DataBind 方法。Therefore, you do not need to explicitly call the DataBind method.

適用于

另請參閱

總結

以上是生活随笔為你收集整理的select html value属性,HtmlSelect.DataValueField 属性 (System.Web.UI.HtmlControls) | Microsoft Docs...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 影音先锋丝袜美腿 | 在线色av| 偷拍老头老太高潮抽搐 | 一区三区视频 | 日日日夜夜操 | 精品国产乱码久久久久久蜜臀 | 日本护士体内she精2xxx | 国产精品视频全国免费观看 | av福利片| 疯狂做爰的爽文多肉小说王爷 | 成人在线精品视频 | 亚洲黄色在线观看视频 | 少妇被躁爽到高潮 | 欧美日韩一区二区三区 | 日本一区不卡视频 | 中文字幕乱码视频 | 国产一区在线免费 | 久久精品在线免费观看 | 美腿丝袜av| 日日躁夜夜躁aaaabbbb | 秋霞一区二区三区 | 性欧美hd调教 | 精品欧美一区二区三区久久久 | 国产在线一二三区 | 国产jzjzjz丝袜老师水多 | 国产一区二区在线电影 | 巨乳美女被爆操 | 国产羞羞 | 久久伊人操 | 寡妇激情做爰呻吟 | 人体一级片 | 久久久穴| 嫩草视频在线免费观看 | 日韩欧美一本 | 日韩91 | 亚洲激情偷拍 | 男人操女人网站 | 久久噜噜色综合一区二区 | 日日干夜夜艹 | 免费一区| 日本久久中文字幕 | 67194成人 | 久久精品色欲国产AV一区二区 | 超碰一区| 日韩人妻一区二区三区蜜桃 | 激情网站在线 | 97免费公开视频 | 99激情视频 | 波多野结衣av电影 | 91网站免费在线观看 | 免费看片网站91 | 日本一区二区在线视频 | 亚洲六月婷婷 | 91在线网 | 99riav1国产精品视频 | 黑帮大佬和我的365日第二部 | 最新版天堂资源在线 | 波多野结衣日韩 | 在线视频综合网 | 免费av看片 | av操操操 | 国产精品一二三区视频 | aa毛片视频 | 欧美日韩激情网 | 国产精品天天干 | 国产婷婷在线视频 | 中文字幕免费高清 | 色久在线| 91国模| 激烈的性高湖波多野结衣 | 国产成人免费视频网站 | 国产不卡在线观看 | 777四色 | www国产亚洲精品久久麻豆 | 日韩一区二区三区在线视频 | 亚洲网址在线观看 | 偷拍xxxx| 一区视频网站 | 老汉av在线 | 免费成人高清在线视频 | 亚洲av中文无码乱人伦在线视色 | 性生交大全免费看 | 日本人视频69式jzzij | 泷泽萝拉在线播放 | 91看片在线看 | 日韩av在线一区二区三区 | 国产永久免费视频 | 欧洲一区二区在线观看 | 午夜欧美精品 | 日韩国产第一页 | 懂色av一区 | 久久人人妻人人人人妻性色av | 综合久久激情 | 国产成人综合久久 | 中文字幕69 | 日韩操操操 | 美女扒开尿口让男人爽 | 日韩www在线观看 | 长篇高h乱肉辣文 |