在上传图库时订购图库 [英] Order gallery images as they are uploaded

查看:80
本文介绍了在上传图库时订购图库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的asp.net网站上使用facebox作为我的图片库。当我将图像上传到图库时,它们保存在我的光盘上,网址数据存储在我的sql数据库中。上传后,我的图库会显示图片中的缩略图,但不会按照上传的顺序显示。我想在库中首先显示上次上传的图像(按上次上传的顺序),但我不知道我应该在代码中添加什么。



这是代码:





I am using facebox on my asp.net web site for my image gallery. when i am uploading images to the gallery, they are saved on my disc and url data is stored in my sql database. After the uploading, my gallery displays thumbnails from the images but not in the order as they are uploaded. I want to display the last uploaded image as first in the gallery (order by last uploaded), but i don't know what i should add in the code.

This is the code:


<body style="background-color:black">
 <script type="text/javascript" charset="utf-8">
     $(function () {
         $('[rel^="FaceBox"]').FaceBox();
     });
    </script>
<form id="form1" runat="server">
  <div class="Znamenitosti" id="Znamenitosti">
         <asp:DataList ID="dlImages" runat="server" RepeatColumns="7" CellPadding="3"  >
 <ItemTemplate>
<div class="boxButton">
<ul class="Gallery" >
 <li><a id="A1"   href='<%# Eval("ime","~/Sliki/Ohrid/Znamenitosti/{0}") %>' title='<%#   "Од "+ Eval("userid")+ ", на " +  Eval("datum")+ ", " +  Eval("opis")%>'  rel="FaceBox[gallery1]"   runat="server" >
 <asp:Image ID="Image1"  ImageUrl='<%# Bind("imethumb",  "~/Sliki/Ohrid/Znamenitosti/thumb/{0}") %>' runat="server" Width="140" Height="140" AlternateText='<%# Bind("imeslika") %>' />
 </a></li></ul></div>
 </ItemTemplate>
 </asp:DataList>
 </div>





Cs代码:





Cs code:

 protected void Page_Load(object sender, EventArgs e)
{

    if (!IsPostBack)
    {

        BindDataList();


    }

}     
   protected void BindDataList()
{
    String strConnString = System.Configuration.ConfigurationManager
        .ConnectionStrings["makbazaConnectionString"].ConnectionString;
    SqlConnection con = new SqlConnection(strConnString);
    con.Open();
    if (Request.QueryString["ID"] == "Znamenitosti")
    {
        //Query to get ImagesName and Description from database

        SqlCommand command = new SqlCommand("SELECT ime, imethumb, imeslika, kategorija, datum, opis, slikapateka, thumbpateka, userid FROM Ohrid WHERE kategorija='Znamenitosti' AND grad='Ohrid' ", con);
        SqlDataAdapter da = new SqlDataAdapter(command);
        DataTable dt = new DataTable();
        da.Fill(dt);
        dlImages.DataSource = dt;
        dlImages.DataBind();
    }
    .
    .
    .
    .
    con.Close();
}

推荐答案

(function(){
(function () {


('[rel ^ =FaceBox]')。FaceBox();
});
< / script>
< form id =form1runat =server>
< div class =Znamenitostiid =Znamenitosti>
< asp:DataList ID =dlImagesrunat =serverRepeatColumns =7CellPadding =3>
< ItemTemplate>
< div class =boxButton>
< ul class =Gallery>
< li>< a id =A1href ='<%#Eval(ime,〜/ Sliki / Ohrid / Znamenitosti / {0})%>'title =' <%#Од+ Eval(userid)+,на+ Eval(datum)+,+ Eval(opis)%>'rel =FaceBox [gallery1]runat =服务器>
< asp:图片ID =Image1ImageUrl ='<%#Bind(imethumb,〜/ Sliki / Ohrid / Znamenitosti / thumb / {0})%>'runat = serverWidth =140Height =140AlternateText ='<%#Bind(imeslika)%>'/>
< / a>< / li>< / ul>< / div>
< / ItemTemplate>
< / asp:DataList>
< / div>
('[rel^="FaceBox"]').FaceBox(); }); </script> <form id="form1" runat="server"> <div class="Znamenitosti" id="Znamenitosti"> <asp:DataList ID="dlImages" runat="server" RepeatColumns="7" CellPadding="3" > <ItemTemplate> <div class="boxButton"> <ul class="Gallery" > <li><a id="A1" href='<%# Eval("ime","~/Sliki/Ohrid/Znamenitosti/{0}") %>' title='<%# "Од "+ Eval("userid")+ ", на " + Eval("datum")+ ", " + Eval("opis")%>' rel="FaceBox[gallery1]" runat="server" > <asp:Image ID="Image1" ImageUrl='<%# Bind("imethumb", "~/Sliki/Ohrid/Znamenitosti/thumb/{0}") %>' runat="server" Width="140" Height="140" AlternateText='<%# Bind("imeslika") %>' /> </a></li></ul></div> </ItemTemplate> </asp:DataList> </div>





Cs代码:





Cs code:

 protected void Page_Load(object sender, EventArgs e)
{

    if (!IsPostBack)
    {

        BindDataList();


    }

}     
   protected void BindDataList()
{
    String strConnString = System.Configuration.ConfigurationManager
        .ConnectionStrings["makbazaConnectionString"].ConnectionString;
    SqlConnection con = new SqlConnection(strConnString);
    con.Open();
    if (Request.QueryString["ID"] == "Znamenitosti")
    {
        //Query to get ImagesName and Description from database

        SqlCommand command = new SqlCommand("SELECT ime, imethumb, imeslika, kategorija, datum, opis, slikapateka, thumbpateka, userid FROM Ohrid WHERE kategorija='Znamenitosti' AND grad='Ohrid' ", con);
        SqlDataAdapter da = new SqlDataAdapter(command);
        DataTable dt = new DataTable();
        da.Fill(dt);
        dlImages.DataSource = dt;
        dlImages.DataBind();
    }
    .
    .
    .
    .
    con.Close();
}


步骤1:我建议您在表格中添加uploaddatetime字段,并针对所有图像捕获上传的日期时间。 />


第2步:在您的选择查询中:

SELECT ime,imethumb,imeslika,kategorija,datum,opis,slikapateka,thumbpateka,userid FROM Ohrid WHERE kategorija ='Znamenitosti'AND grad ='Ohrid'通过uploaddatetime desc添加订单。



您的查询变为



SELECT ime,imethumb,imeslika,kategorija,datum,opis,slikapateka,thumbpateka,userid FROM Ohrid WHERE kategorija ='Znamenitosti'AND grad ='Ohrid'ORDER BY UploadDateTime DESC
step 1: I would suggest you to add a uploaddatetime field to your table and capture the uploaded datetime against all the images.

step 2: In your select query :
"SELECT ime, imethumb, imeslika, kategorija, datum, opis, slikapateka, thumbpateka, userid FROM Ohrid WHERE kategorija='Znamenitosti' AND grad='Ohrid' " add an order by uploaddatetime desc.

your query becomes

SELECT ime, imethumb, imeslika, kategorija, datum, opis, slikapateka, thumbpateka, userid FROM Ohrid WHERE kategorija='Znamenitosti' AND grad='Ohrid' ORDER BY UploadDateTime DESC


这篇关于在上传图库时订购图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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