using placeholders

Discussion in 'ASP .Net Web Controls' started by Ian Jagger, Mar 27, 2006.

  1. Ian Jagger

    Ian Jagger Guest

    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
     
    Ian Jagger, Mar 27, 2006
    #1
    1. Advertising

  2. 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/d...ml/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
     
    Phillip Williams, Mar 27, 2006
    #2
    1. Advertising

  3. Ian Jagger

    Ian Jagger Guest

    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;
    }


    "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/d...ml/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
     
    Ian Jagger, Mar 27, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bill Belliveau
    Replies:
    0
    Views:
    380
    Bill Belliveau
    Aug 19, 2003
  2. Colin Basterfield

    PlaceHolders

    Colin Basterfield, Dec 23, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    632
    Colin Basterfield
    Dec 24, 2003
  3. DotNetGruven

    Nested PlaceHolders

    DotNetGruven, Mar 2, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    641
    Steven Cheng[MSFT]
    Mar 5, 2004
  4. buran
    Replies:
    1
    Views:
    431
    Bruno Sirianni
    Apr 6, 2004
  5. Alan Silver
    Replies:
    3
    Views:
    466
    Clint Hill
    Jul 25, 2005
Loading...

Share This Page