Home All Groups Group Topic Archive Search About

Bind DropDownList to XmlDataSource

Author
25 Nov 2005 1:51 PM
Thor W Hammer
Is it possible??

Author
25 Nov 2005 3:21 PM
John Timney ( MVP )
sure is

http://www.eggheadcafe.com/articles/20011128.asp

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

Show quoteHide quote
"Thor W Hammer" <thorwham***@hotmail.com> wrote in message
news:438716ed$1@news.broadpark.no...
> Is it possible??
>
>
Are all your drivers up to date? click for free checkup

Author
26 Nov 2005 10:17 AM
Wouter van Vugt
Hi Thor,

the following ASPX shows it is possible. You do have to bind to an
attribute though. I wasn't able to bind to a inner child.

Grtz, Wouter van Vugt
Trainer - Info Support - www.infosupport.com
www.dive-in-it.nl

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected override void OnLoad(EventArgs e)
    {
        DropDownList1.DataBind();
        base.OnLoad(e);
    }


</script>

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

            </asp:DropDownList>
            <asp:XmlDataSource ID="XmlDataSource1" runat="server">
                <Data>
<Customers>
  <Customer id="Customer1">
    <ID>Customer1</ID>
    <Name>First Customer</Name>
  </Customer>
  <Customer id="Customer2">
    <ID>Customer2</ID>
    <Name>Second Customer</Name>
  </Customer>
  <Customer id="Customer3">
    <ID>Customer3</ID>
    <Name>Third Customer</Name>
  </Customer>
  <Customer id="Customer4">
    <ID>Customer4</ID>
    <Name>Fourth Customer</Name>
  </Customer>
</Customers></Data>

            </asp:XmlDataSource>
        </div>
    </form>
</body>
</html>

Bookmark and Share