W3Schools.com

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
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE