ryukenblaze
04-12-2009, 06:52 PM
Okay, so Im trying to bind data from an XML page to an ASP.Net page language VB. at first it displayed the first round of choices: ID codes, but not travel destinations, so I switched the values of the fields. Now nothing. I undid the change, but it still wont show anything but the label used for output. the goal was to bind the xml so the data appeared as radio buttons in the aspx page. According to all my resources, this should work but its not. Help please!
Here is my code:
First the XML:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="basic.xsl" ?>
<Vacations>
<Trip>
<TripID>452009</TripID>
<Destination>Tokyo, Japan</Destination>
</Trip>
<Trip>
<TripID>5302009</TripID>
<Destination>New York, New York</Destination>
</Trip>
<Trip>
<TripID>6212009</TripID>
<Destination>London, England</Destination>
</Trip>
<Trip>
<TripID>8152009</TripID>
<Destination>Paris, France</Destination>
</Trip>
<Trip>
<TripID>12212009</TripID>
<Destination>Hiroshima-Kyoto, Japan</Destination>
</Trip>
</Vacations>
Now the asp.net in vb:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load()
If Not Page.IsPostBack Then
Dim myvacay = New DataSet
myvacay.ReadXml(MapPath("Vacation.xml"))
rb.DataSource = myvacay
rb.DataValueField = "Destination"
rb.DataTextField = "TripID"
rb.DataBind()
End If
End Sub
Sub displayMessage(ByVal s As Object, ByVal e As EventArgs)
lbl1.text = "You chose to go to: " & rb.SelectedItem.Text
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButtonList id="rb" runat="server"
AutoPostBack="True" onSelectedIndexChanged="displayMessage"/>
</div>
<asp:Label ID="lbl1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
Here is my code:
First the XML:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="basic.xsl" ?>
<Vacations>
<Trip>
<TripID>452009</TripID>
<Destination>Tokyo, Japan</Destination>
</Trip>
<Trip>
<TripID>5302009</TripID>
<Destination>New York, New York</Destination>
</Trip>
<Trip>
<TripID>6212009</TripID>
<Destination>London, England</Destination>
</Trip>
<Trip>
<TripID>8152009</TripID>
<Destination>Paris, France</Destination>
</Trip>
<Trip>
<TripID>12212009</TripID>
<Destination>Hiroshima-Kyoto, Japan</Destination>
</Trip>
</Vacations>
Now the asp.net in vb:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load()
If Not Page.IsPostBack Then
Dim myvacay = New DataSet
myvacay.ReadXml(MapPath("Vacation.xml"))
rb.DataSource = myvacay
rb.DataValueField = "Destination"
rb.DataTextField = "TripID"
rb.DataBind()
End If
End Sub
Sub displayMessage(ByVal s As Object, ByVal e As EventArgs)
lbl1.text = "You chose to go to: " & rb.SelectedItem.Text
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButtonList id="rb" runat="server"
AutoPostBack="True" onSelectedIndexChanged="displayMessage"/>
</div>
<asp:Label ID="lbl1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>