db00707 Posted October 23, 2007 Share Posted October 23, 2007 Hi,I'm having a problem with this:http://www.w3schools.com/aspnet/aspnet_repeater.aspI'm using ASP.Net 2.0.I have the xml file but when it runs I just see a blank page.There are no errors generated.Any ideas why it might not be working?Thanks. Link to comment Share on other sites More sharing options...
aspnetguy Posted October 23, 2007 Share Posted October 23, 2007 please post all relavent code. We'll need to see what is going on. Link to comment Share on other sites More sharing options...
db00707 Posted October 23, 2007 Author Share Posted October 23, 2007 please post all relavent code. We'll need to see what is going on.There's not much code at all.... it uses vb and one file... say default.aspxdefault.aspx.vb:-sub Page_Loadif Not Page.IsPostBack then dim mycdcatalog=New DataSet mycdcatalog.ReadXml(MapPath("cdcatalog.xml"))end ifend subdefault.aspx:-<%@ Import Namespace="System.Data" %><html><body><form runat="server"><asp:Repeater id="cdcatalog" runat="server"><HeaderTemplate><table border="1" width="100%"><tr><th>Title</th><th>Artist</th><th>Country</th><th>Company</th><th>Price</th><th>Year</th></tr></HeaderTemplate><ItemTemplate><tr><td><%#Container.DataItem("title")%></td><td><%#Container.DataItem("artist")%></td><td><%#Container.DataItem("country")%></td><td><%#Container.DataItem("company")%></td><td><%#Container.DataItem("price")%></td><td><%#Container.DataItem("year")%></td></tr></ItemTemplate><FooterTemplate></table></FooterTemplate></asp:Repeater></form></body></html>the xml file:-<?xml version="1.0" encoding="ISO-8859-1"?><catalog><cd><title>Empire Burlesque</title><artist>Bob Dylan</artist><country>USA</country><company>Columbia</company><price>10.90</price><year>1985</year></cd><cd><title>Hide your heart</title><artist>Bonnie Tyler</artist><country>UK</country><company>CBS Records</company><price>9.90</price><year>1988</year></cd><cd><title>Greatest Hits</title><artist>Dolly Parton</artist><country>USA</country><company>RCA</company><price>9.90</price><year>1982</year></cd><cd><title>Still got the blues</title><artist>Gary Moore</artist><country>UK</country><company>Virgin records</company><price>10.20</price><year>1990</year></cd><cd><title>Eros</title><artist>Eros Ramazzotti</artist><country>EU</country><company>BMG</company><price>9.90</price><year>1997</year></cd></catalog>That's it.Thanks. Link to comment Share on other sites More sharing options...
aspnetguy Posted October 23, 2007 Share Posted October 23, 2007 you left out the databinding. change your vb to look like this sub Page_Loadif Not Page.IsPostBack thendim mycdcatalog=New DataSetmycdcatalog.ReadXml(MapPath("cdcatalog.xml"))cdcatalog.DataSource = mycdcatalogcdcatalog.DataBind()end ifend sub Link to comment Share on other sites More sharing options...
db00707 Posted October 24, 2007 Author Share Posted October 24, 2007 you left out the databinding. change your vb to look like thissub Page_Loadif Not Page.IsPostBack thendim mycdcatalog=New DataSetmycdcatalog.ReadXml(MapPath("cdcatalog.xml"))cdcatalog.DataSource = mycdcatalogcdcatalog.DataBind()end ifend sub Hi,I have tried that but I still get a blank Internet Explorer.Could there be anything wrong with this line: mycdcatalog.ReadXml(MapPath("cdcatalog.xml")) ?Thanks Link to comment Share on other sites More sharing options...
Reg Edit Posted October 24, 2007 Share Posted October 24, 2007 Hi,I'm having a problem with this:http://www.w3schools.com/aspnet/aspnet_repeater.aspI'm using ASP.Net 2.0.I have the xml file but when it runs I just see a blank page.There are no errors generated.Any ideas why it might not be working?Thanks.The tutorial example uses .NET 1.x syntax. Since you're using .NET 2.0, your Page_Load is not recognized as a page load event handler with that declaration, so your code never executes. You need to use:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Link to comment Share on other sites More sharing options...
aspnetguy Posted October 24, 2007 Share Posted October 24, 2007 thanks for pointing that out I don't use VB so I would never have caught that. Link to comment Share on other sites More sharing options...
db00707 Posted October 25, 2007 Author Share Posted October 25, 2007 Thanks for that.I'd just cut & paste the code, and ignored the event handler.... completely missed that. I wasn't aware it was asp.net 1.0... another gotcha.... especially as I've only used asp.net from v2.0 !Thanks again... much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.