Click here to Skip to main content
15,922,166 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: POST variable from java applet to web page Pin
__makaveli__19-Feb-06 22:06
__makaveli__19-Feb-06 22:06 
GeneralRe: POST variable from java applet to web page Pin
George L. Jackson20-Feb-06 13:09
George L. Jackson20-Feb-06 13:09 
GeneralRe: POST variable from java applet to web page Pin
__makaveli__20-Feb-06 21:54
__makaveli__20-Feb-06 21:54 
Questionwindow.defaultStatus Not working in Mozilla and Netscape Pin
Brendan Vogt16-Feb-06 22:16
Brendan Vogt16-Feb-06 22:16 
AnswerRe: window.defaultStatus Not working in Mozilla and Netscape Pin
George L. Jackson18-Feb-06 2:30
George L. Jackson18-Feb-06 2:30 
AnswerRe: window.defaultStatus Not working in Mozilla and Netscape Pin
Shog920-Feb-06 6:08
sitebuilderShog920-Feb-06 6:08 
QuestionHow to record how many users have downloaded my softwares? Pin
Iftikhar Ali16-Feb-06 20:54
Iftikhar Ali16-Feb-06 20:54 
AnswerRe: How to record how many users have downloaded my softwares? Pin
PrakashBhaskar20-Feb-06 23:44
PrakashBhaskar20-Feb-06 23:44 
QuestionRe: How to record how many users have downloaded my softwares? Pin
Iftikhar Ali21-Feb-06 20:38
Iftikhar Ali21-Feb-06 20:38 
Questioncalendar grid Pin
alxtech16-Feb-06 9:36
alxtech16-Feb-06 9:36 
QuestionPrinting web page in landscape Pin
idreesbadshah16-Feb-06 7:09
idreesbadshah16-Feb-06 7:09 
AnswerRe: Printing web page in landscape Pin
Dmitry Khudorozhkov17-Feb-06 7:46
Dmitry Khudorozhkov17-Feb-06 7:46 
GeneralRe: Printing web page in landscape Pin
idreesbadshah21-Feb-06 7:22
idreesbadshah21-Feb-06 7:22 
QuestionSelling Files Pin
LittleYellowBird16-Feb-06 7:00
LittleYellowBird16-Feb-06 7:00 
AnswerRe: Selling Files Pin
Iftikhar Ali16-Feb-06 20:42
Iftikhar Ali16-Feb-06 20:42 
QuestionHELP! - Class file appears to shared accross sessions? ASP VB.NET Pin
Morgan198116-Feb-06 6:21
Morgan198116-Feb-06 6:21 
Questionpublish my web project in LAN Pin
kenny923915-Feb-06 22:38
kenny923915-Feb-06 22:38 
AnswerRe: publish my web project in LAN Pin
Curtis Schlak.16-Feb-06 13:12
Curtis Schlak.16-Feb-06 13:12 
QuestionAsynchronous web search Pin
sammyl3315-Feb-06 7:48
sammyl3315-Feb-06 7:48 
AnswerRe: Asynchronous web search Pin
Shog915-Feb-06 8:40
sitebuilderShog915-Feb-06 8:40 
GeneralRe: Asynchronous web search Pin
sammyl3315-Feb-06 12:13
sammyl3315-Feb-06 12:13 
QuestionDetect Windows XP SP2 Pin
Chintoo72315-Feb-06 1:59
Chintoo72315-Feb-06 1:59 
AnswerRe: Detect Windows XP SP2 Pin
DJLarZ16-Feb-06 2:55
DJLarZ16-Feb-06 2:55 
Questionbeginner problem with databinding Pin
Bart Blommerde14-Feb-06 22:30
Bart Blommerde14-Feb-06 22:30 
After a few evenings of doing tutorials and trying things out, I just encountered my first reallife .NET problem. It concerns dynamic databinding of a Repeater control, using C# and Visual Studio 2005.

For the purpose of binding a number of XML datasources (RSS feeds) to multiple Repeater controls, I made my own implementation of the ITemplate interface :

<br />
public class RssTemplate : ITemplate<br />
{<br />
  static int itemcount = 0;<br />
  ListItemType templateType;<br />
  string title;<br />
  <br />
  public RssTemplate(ListItemType type)<br />
  {<br />
    templateType = type;<br />
  }<br />
<br />
  public RssTemplate(ListItemType type, string t)<br />
  {<br />
    templateType = type;<br />
    title = t;<br />
  }<br />
<br />
  private void TemplateControl_DataBinding(object sender, System.EventArgs e)<br />
  {<br />
    Literal lc;<br />
    lc = (Literal)sender;<br />
    RepeaterItem container = (RepeaterItem)lc.NamingContainer;<br />
    lc.Text = "<a href=\""; <br />
    lc.Text += XPathBinder.Eval(container.DataItem, "link").ToString();<br />
    lc.Text += "\">";<br />
    lc.Text += XPathBinder.Eval(container.DataItem, "title").ToString();<br />
    lc.Text += "</a><br />";<br />
  }<br />
<br />
  public void InstantiateIn(System.Web.UI.Control container)<br />
  {<br />
    Literal lc = new Literal();<br />
    switch (templateType)<br />
    {<br />
    case ListItemType.Header:<br />
      lc.Text = "<b>" + title + "</b><br>";<br />
      break;<br />
    case ListItemType.Item:<br />
      lc.DataBinding += new EventHandler(TemplateControl_DataBinding);<br />
      break;<br />
    case ListItemType.Footer:<br />
      lc.Text = "<br />";<br />
      break;<br />
    }<br />
    container.Controls.Add(lc);<br />
    itemcount += 1;<br />
  }<br />
}<br />



Now I want to loop through a collection of XML urls, fetch the content and bind each dataset to a different Repeater control (see code below). The problem is that the Databind() function, which should bind all datasources to their corresponding controls, binds every control to the first Datasource. I end up having multiple copies of the same RSS items on my page.

I'm sure it's something very trivial I'm overlooking here or it might be that my approach is wrong altogether, but if someone could push me in the right direction here, I would be very grateful.

<br />
OleDbDataReader dtr = cmd.ExecuteReader();<br />
WebFetch wf = new WebFetch();<br />
while (dtr.Read())<br />
{<br />
  // Get RSS feed.<br />
  XmlDataSource xmlds = new XmlDataSource();<br />
  xmlds.Data = wf.fetchURL(dtr.GetString(2));<br />
  xmlds.XPath = "rss/channel/item";<br />
  <br />
  // Construct new repeater control. <br />
  Repeater rss_repeater = new Repeater();<br />
  rss_repeater.DataSource = xmlds;<br />
  rss_repeater.HeaderTemplate = new RssTemplate(ListItemType.Header, dtr.GetString(1));<br />
  rss_repeater.FooterTemplate = new RssTemplate(ListItemType.Footer);<br />
  rss_repeater.ItemTemplate = new RssTemplate(ListItemType.Item);<br />
  RssPlaceHolder.Controls.Add(rss_repeater);<br />
}<br />
dtr.Close();<br />
DataBind();<br />


As stated above : why does DataBind() bind all instances of the Repeater class to the same instance of XMLDataSource, where it should bind (in my opinion) to different instances of XMLDataSource?



-- modified at 4:32 Wednesday 15th February, 2006
AnswerRe: beginner problem with databinding Pin
Bart Blommerde15-Feb-06 9:47
Bart Blommerde15-Feb-06 9:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.