|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
using placeholdersHi,
I am trying to dynamically read data from the database and display it as a series of hyperlinks in an unordered list on a web page. I added a placeholder to the page and added controls from the database to the pageholder. I've verified that it is adding controls by debugging it, however when I run the page the placeholder's content does not show up. I've made the placeholders visible and I've also added unique ids for the hyperlinks. Does anyone have any ideas on how to get this working? Regards, Ian To display a HyperLink make sure you supplied value to the ImageURL or the
Text properties of the HyperLink server control. As for making them databound you might consider using the repeater which allows you to split the markup between several templates: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconintroductiontohyperlinkwebcontrol.asp <asp:Repeater ID="repeater1" Runat="server"> <HeaderTemplate> <ul> </HeaderTemplate> <ItemTemplate> <li> <asp:HyperLink ID="hlink" Runat="server" NavigateUrl='<%#DataBinder.Eval(Container.DataItem,"NavigateURLField")%>' Text='<%#DataBinder.Eval(Container.DataItem,"URLTitle")%>'></asp:HyperLink> </li> </ItemTemplate> <FooterTemplate> </ul> </FooterTemplate> </asp:Repeater> Show quoteHide quote "Ian Jagger" wrote: > Hi, > > I am trying to dynamically read data from the database and display it as a > series of hyperlinks in an unordered list on a web page. > > I added a placeholder to the page and added controls from the database to > the pageholder. I've verified that it is adding controls by debugging it, > however when I run the page the placeholder's content does not show up. > > I've made the placeholders visible and I've also added unique ids for the > hyperlinks. > > Does anyone have any ideas on how to get this working? > > Regards, > > Ian Hi,
I guess I should say that I have a dataset that could be created by one of two sps in the codebehind, and that I only want some of the data to be databound. I have either a list of places or customer names and I want to display a page navigation (eg A, B, C, D etc where there are customers) as hyperlinks and a list of the names that relate to the letter chosen on the page. eg there would be a list of letters where there are customers and a list of customers matching the letter. There are only about 500 customers so retrieving a list of places or a list of names will not be a problem, but would rather not do it too often. So I need programatic control of the data or else there will be a lot of different sp calls. This is also the first of a few data aware pages. I have in the past used tables and added stuff to it and it has worked, but I have been informed that they are a bad thing and so we are using css and hence placeholders. Here is what I have, and the page_load event assigns the results of this function to the Placeholder. PlaceHolder getAgents (DataSet ds, string first) { PlaceHolder ps = new PlaceHolder(); // try { foreach (DataRow dr in ds.Tables[0].Rows) { string agent = dr [0].ToString(); if (agent.Length >= 1) { string fl = agent.Substring (0, 1); if (fl == first) { HyperLink hyp = new HyperLink (); hyp.Text = agent; if (ViewState ["type"].ToString() == "loc") { hyp.NavigateUrl = "Agents.aspx?loc=" + HttpUtility.UrlEncode (agent); } else { hyp.NavigateUrl = "Agent.aspx?agent=" + HttpUtility.UrlEncode (agent); } hyp.ID = "br" + agent; ps.Controls.Add (hyp); } } } } // catch (Exception ex) { } return ps; } Show quoteHide quote "Phillip Williams" wrote: > To display a HyperLink make sure you supplied value to the ImageURL or the > Text properties of the HyperLink server control. > > As for making them databound you might consider using the repeater which > allows you to split the markup between several templates: > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconintroductiontohyperlinkwebcontrol.asp > > <asp:Repeater ID="repeater1" Runat="server"> > <HeaderTemplate> > <ul> > </HeaderTemplate> > <ItemTemplate> > <li> > <asp:HyperLink ID="hlink" Runat="server" > NavigateUrl='<%#DataBinder.Eval(Container.DataItem,"NavigateURLField")%>' > Text='<%#DataBinder.Eval(Container.DataItem,"URLTitle")%>'></asp:HyperLink> > </li> > </ItemTemplate> > <FooterTemplate> > </ul> > </FooterTemplate> > </asp:Repeater> > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "Ian Jagger" wrote: > > > Hi, > > > > I am trying to dynamically read data from the database and display it as a > > series of hyperlinks in an unordered list on a web page. > > > > I added a placeholder to the page and added controls from the database to > > the pageholder. I've verified that it is adding controls by debugging it, > > however when I run the page the placeholder's content does not show up. > > > > I've made the placeholders visible and I've also added unique ids for the > > hyperlinks. > > > > Does anyone have any ideas on how to get this working? > > > > Regards, > > > > Ian
Adding controls to Pager row in GridView
Templated control not rendering Web User Controls Trouble with validator control ? Script not found Is there a free .GIF software? Trouble with validator control ? script not found Display data in asp:Calendar servercontrols (webcontrols, htmlcontrols) or html elements? Gridview and colspan Scroll position in panel control Adding AutoPostBack to a webcontrol |
|||||||||||||||||||||||