471,049 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,049 software developers and data experts.

populate checkboxlist from XmlDataSource (ASP.net 2.0)

can somebody please show me some code that will let me populate a
checkboxlist from the xmldatasource, and have the text property set to the
names in the xml file

thanks
you can also email me at i_****************@hotmail.com
Nov 19 '05 #1
2 3043
mike <mi**@discussions.microsoft.com> ha scritto:
can somebody please show me some code that will let me populate a
checkboxlist from the xmldatasource, and have the text property set
to the names in the xml file

thanks


With this XML file:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<item value="1" text="Value 1" />
<item value="2" text="Value 2" />
<item value="3" text="Value 3" />
</root>

And this code:
<asp:CheckBoxList ID="CheckBoxList1" runat="server"
DataSourceID="XmlDataSource1"
DataTextField="text" DataValueField="value">
</asp:CheckBoxList><asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/Data/XMLFile.xml"></asp:XmlDataSource>

--
AZ [Microsoft - .NET MVP]
Mia Home page: http://ciclismo.sitiasp.it
Asp.Net community: http://www.aspitalia.com
Il mio blog: http://blogs.aspitalia.com/az
Nov 19 '05 #2
<Lookup>
<Lookup_Entry>
<Ts>
<T>
<M>context</M>
<V>type</V>
<Va>Citizen</Va>
</T>
</Ts>
<U>.html</U>
</Lookup_Entry>
</Lookup>
example of xml file is above

code:
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Lookup
table.xml"
XPath='/Lookup/Lookup_Entry/Ts/T/Va[../../T[M = "context" and V
= "type"]]'>
</asp:XmlDataSource>
<asp:CheckBoxList
ID="CheckBoxList1"
runat="server"
DataSourceID="XmlDataSource1">
</asp:CheckBoxList>

Now how do i get each <Va> that is returned with the xmldatasource as a item
in my checkboxlist

displayed now when run is with a checkbox to the left of each item:
System.Web.UI.WebControls.XmlDataSourceNodeDescrip tor
System.Web.UI.WebControls.XmlDataSourceNodeDescrip tor
System.Web.UI.WebControls.XmlDataSourceNodeDescrip tor
System.Web.UI.WebControls.XmlDataSourceNodeDescrip tor
System.Web.UI.WebControls.XmlDataSourceNodeDescrip tor
System.Web.UI.WebControls.XmlDataSourceNodeDescrip tor
System.Web.UI.WebControls.XmlDataSourceNodeDescrip tor

mike

"Andrea Zani" wrote:
mike <mi**@discussions.microsoft.com> ha scritto:
can somebody please show me some code that will let me populate a
checkboxlist from the xmldatasource, and have the text property set
to the names in the xml file

thanks


With this XML file:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<item value="1" text="Value 1" />
<item value="2" text="Value 2" />
<item value="3" text="Value 3" />
</root>

And this code:
<asp:CheckBoxList ID="CheckBoxList1" runat="server"
DataSourceID="XmlDataSource1"
DataTextField="text" DataValueField="value">
</asp:CheckBoxList><asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/Data/XMLFile.xml"></asp:XmlDataSource>

--
AZ [Microsoft - .NET MVP]
Mia Home page: http://ciclismo.sitiasp.it
Asp.Net community: http://www.aspitalia.com
Il mio blog: http://blogs.aspitalia.com/az

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Shaul Feldman | last post: by
4 posts views Thread by Patrick.O.Ige | last post: by
reply views Thread by mike | last post: by
2 posts views Thread by Zulander | last post: by
1 post views Thread by Disccooker | last post: by
8 posts views Thread by Wessel Troost | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.