Showing posts with label xmldatasource. Show all posts
Showing posts with label xmldatasource. Show all posts

Monday, March 26, 2012

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_am_the_freshmaka@dotnet.itags.org.hotmail.commike <mike@.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
<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.XmlDataSourceNodeDescriptor
System.Web.UI.WebControls.XmlDataSourceNodeDescriptor
System.Web.UI.WebControls.XmlDataSourceNodeDescriptor
System.Web.UI.WebControls.XmlDataSourceNodeDescriptor
System.Web.UI.WebControls.XmlDataSourceNodeDescriptor
System.Web.UI.WebControls.XmlDataSourceNodeDescriptor
System.Web.UI.WebControls.XmlDataSourceNodeDescriptor
mike
"Andrea Zani" wrote:

> mike <mike@.discussions.microsoft.com> ha scritto:
> 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
>
>

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_am_the_freshmaka@dotnet.itags.org.hotmail.commike <mike@.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
<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 <mike@.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
>