Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this code:

HTML
$(document).ready(function () {


        $('#Priroda').hide();

        $('#priroda_').click(function () {
            $('#Znamenitosti').hide();
            $('#Priroda').show();


        });

        $('#znamenitosti_').click(function () {
            $('#Priroda').hide();
            $('#Znamenitosti').show();
        });
    });


</script>
 <div class="meni">
    <nav>
    <ul>
    <li class="active"><a href="#">Info</a></li>
    <li><a href="#" id="znamenitosti_">Znamenitosti</a></li>
    <li><a href="#" id="priroda_">Priroda</a></li>
    <li><a href="#" id="nokenzivot_">Noken Zivot</a></li>
     </ul>
        </nav>
        </div>


where I have few categories in the menu. When i click on specific category, i want to show the (div) tag for that specific category within the same .aspx page, and the other (div) tags for the other categories should be hidden. This is the (div) tag for the category "Priroda":

<div class="Priroda" id="Priroda">
         <asp:DataList ID="DataList1" runat="server" RepeatColumns="7" CellPadding="3">
  <ItemTemplate>
<div class="boxButton">
<ul class="Gallery">
<li><a id="A1"  href='<%# Eval("ime","~/Sliki/Ohrid/Priroda/{0}") %>' title='<%# "Од "+ Eval("userid")+ ", на " +  Eval("datum")+ ", " +  Eval("opis")%>'  rel="FaceBox[gallery1]"  runat="server" >
 <asp:Image ID="Image1"  ImageUrl='<%# Bind("ime", "~/Sliki/Ohrid/Priroda/{0}") %>' runat="server" Width="140" Height="140" AlternateText='<%# Bind("imeslika") %>' />
 </a></li></ul></div>
 </ItemTemplate>
 </asp:DataList>
    </div>


For binding the DataList i used this code in .cs file:

protected void BindDataList1()
{
    String strConnString = System.Configuration.ConfigurationManager
        .ConnectionStrings["makbazaConnectionString"].ConnectionString;
    SqlConnection con = new SqlConnection(strConnString);
    con.Open();
    //Query to get ImagesName and Description from database
    SqlCommand command = new SqlCommand("SELECT ime, imeslika, kategorija, datum, opis, slikapateka, userid FROM Ohrid WHERE kategorija='Priroda'", con);
    SqlDataAdapter da = new SqlDataAdapter(command);
    DataTable dt = new DataTable();
    da.Fill(dt);
    dlImages.DataSource = dt;
    dlImages.DataBind();
    con.Close();
}


Now i don't know how to call BindDataList1(); to show me data when i click on that category. I have different BindDataLists for each category. Can you tell me how to call specific BindDataList for the category that is selected from the menu? For example when i click on link Priroda show me the (div) tag Priroda and BindDalaList1();, when i click on link Znamenitosti show me the (div) tag Znamenitosti and BindDalaList2();
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900