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

问题描述

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

推荐答案






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



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

08-31 06:50