Search w3schools.com:

SHARE THIS PAGE

ASP.NET DataValueField Property


ListControl Control Reference Complete ListControl Control Reference

Definition and Usage

The DataValueField property specifies which field from the DataSource to bind to the Value property of each item in the control.


Example

The following example uses an XML file to fill the data of a RadioButtonList:

<%@ Import Namespace="System.Data" %>

<script runat="server">
sub Page_Load
  if Not Page.IsPostBack then
  dim mycountries=New DataSet
  mycountries.ReadXml(MapPath("countries.xml"))
  rb.DataSource=mycountries
  rb.DataValueField="value"
  rb.DataTextField="text"
  rb.DataBind()
  end if
end sub

sub displayMessage(s as Object,e As EventArgs)
  lbl1.text="You selected: " & rb.SelectedItem.Text
end sub
</script>

<form runat="server">
<asp:RadioButtonList id="rb" AutoPostBack="True"
runat="server" onSelectedIndexChanged="displayMessage" />
<asp:label id="lbl1" runat="server" />
</form>

Show example »

The XML file used in the example is countries.xml


ListControl Control Reference Complete ListControl Control Reference

W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The HTML5 Certificate documents your knowledge of advanced HTML5.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]