0

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

1 回答 1

0

基准是您的日期字段吗?

如果是这样,只需修改您的 sqlcommand:

从 Ohrid 选择 ime、imethumb、imeslika、kategorija、datum、opis、slikapateka、thumpateka、userid,其中 kategorija='Znamenitosti' AND grad='Ohrid' ORDER BY DESC datum

干杯,巴特克

于 2013-09-16T06:58:41.760 回答