我有这个代码:
$(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>
我在菜单中有几个类别。当我单击特定类别时,我想在同一个 .aspx 页面中显示该特定类别的 (div) 标签,而其他类别的其他 (div) 标签应该被隐藏。这是“Priroda”类别的 (div) 标签:
<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>
为了绑定 DataList,我在 .cs 文件中使用了以下代码:
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();
}
现在我不知道如何调用 BindDataList1(); 当我单击该类别时向我显示数据。我对每个类别都有不同的 BindDataLists。你能告诉我如何为从菜单中选择的类别调用特定的 BindDataList 吗?例如,当我单击链接 Priroda 时,显示 (div) 标签 Priroda 和 BindDalaList1();,当我单击链接 Znamenitosti 时,显示 (div) 标签 Znamenitosti 和 BindDalaList2();