locked
Hyperlinks inside Accordion/Repeater Pane RRS feed

  • Question

  • User1769015664 posted

    How do I add multiple hyperlinks inside the pane from the database? Currently, it displays "Title" in the header and "Content" inside it.

    <table border="0" >
        <tr>
            <td class="label_topped">
                <div id="dvAccordian" style = "width:400px">
                    <asp:Repeater ID="rptAccordian" runat="server">
                        <ItemTemplate>
                            <h3>
                                <%# Eval("Title") %>
                            </h3>
                            <div>
                                <p>
                                    <%# Eval("Content") %>
                                </p>
                            </div>
                    </ItemTemplate>
                    </asp:Repeater>
                </div>
            </td>
            <td class="auto-style2"></td> 
                    
        </tr>
    </table>
    private void BindRepeater()
        {
            string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "select Title, Content from AccordianContent";
                    cmd.Connection = con;
                    con.Open();
                    rptAccordian.DataSource = cmd.ExecuteReader();
                    rptAccordian.DataBind();
                    con.Close();
                }
            }
        }



    Tuesday, April 18, 2017 9:21 PM

Answers

  • User1769015664 posted

    Never mind; I have figured it out.... My main issue was an extra space at the end of the hyperlink.

    <asp:HyperLink runat="server" NavigateUrl='<%# Eval("Content") %>' Text='<%# Eval("Content") %>'/>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 18, 2017 11:00 PM