在链接上单击菜单BindDataList [英] On link click from menu BindDataList

查看:89
本文介绍了在链接上单击菜单BindDataList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码:



I have this code:

$(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)标签:





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>





为了绑定DataList,我在.cs文件中使用了这段代码:





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





现在我不知道如何调用BindDataList1();当我点击该类别时向我显示数据。我为每个类别都有不同的BindDataLists。你能告诉我如何为从菜单中选择的类别调用特定的BindDataList吗?例如,当我点击链接Priroda告诉我(div)标签Priroda和BindDalaList1();,当我点击链接Znamenitosti给我看(div)标签Znamenitosti和BindDalaList2();



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();

推荐答案

(document).ready(function(){
(document).ready(function () {


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


('#priroda _')。click(function(){
('#priroda_').click(function () {


这篇关于在链接上单击菜单BindDataList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆