0

私はasp.netを初めて使用します。このxllファイルをダウンロードしたのはこのようなものです

    <?xml version="1.0" encoding="utf-8"?>
<countries author="Banmeet Singh" title="Country, State-Province selections"
date="2008-Feb-05">
  <country name="Afghanistan">
    <state>Badakhshan</state>
    <state>Badghis</state>
    <state>Baghlan</state>
    <state>Balkh</state>
    <state>Bamian</state>
    <state>Farah</state>
    <state>Faryab</state>
    <state>Ghazni</state>
    <state>Ghowr</state>
    <state>Helmand</state>
    <state>Herat</state>
    <state>Jowzjan</state>
    <state>Kabol</state>
    <state>Kandahar</state>

そして、リストは続きます。今、ドロップダウンリストに国を表示したいので、ここにpage_loadのc#のコードがあります

     DataSet myDataSet = new DataSet();

        myDataSet.ReadXml(Server.MapPath("xml/country_state.xml"));
        DropDownList1.DataSource = myDataSet;
        DropDownList1.DataBind();
        DropDownList1.DataTextField = "country";
        DropDownList1.DataBind();

Ir はこのエラーを出します: -DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'state' 私が間違っていることを教えてください。ありがとう

わかりました更新、これがhtmlコードです

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>



    </form>
</body>
</html>
4

1 に答える 1