如何将这些帖子设置为降序 asp.net c#
本文关键字:降序 asp net 设置 | 更新日期: 2023-09-27 18:34:47
我正在创建一个社交网络网站作为Facebook,但该网站在姿势状态方面存在一些错误,我使用以下代码发布状态。我在事件和发布按钮上调用了此方法page_Load
private DataSet GetData()
{
string CS=ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlDataAdapter da = new SqlDataAdapter("Select * from PhotoStatusProfile WHERE Email = '" + Session["Email"].ToString() +"'",con);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
}
这是 html 代码
<asp:Repeater runat="server" ID="Repeater1">
<ItemTemplate>
<div class="yourDivClass" style="border-top: thin none #BBCEB3; border-bottom: thin none #BBCEB3; padding: 10px; height: 121px; width: 548px; margin-top: 10px; right: 10px; left: 10px; border-left-width: thin; margin-left: 15px; background-color: #e9eaee; border-left-color: #BBCEB3; border-right-color: #BBCEB3;">
<br />
<div style="width: 58px; height: 62px">
<asp:Image ID="Image1" runat="server" Height="59px" ImageAlign="Top" ImageUrl="~/Profile/Image/supun_Profilemini.jpg" Width="55px" />
</div>
<div style="width: 307px; height: 21px; margin-left: 65px; margin-top: -60px">
<asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Names="Arial" ForeColor="#000066" ><%#Eval("name") %> </asp:Label>
</div>
<div style="height: 22px; width: 461px; margin-left: 78px; margin-top: 11px"> <asp:Label ID="Label8" runat="server"><%#Eval("Status") %></asp:Label>
<br><br>
</div>
</div>
</ItemTemplate>
"开机自检"按钮 CS 代码
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
conn.Open();
try
{
string inserQuery = "insert into PhotoStatusProfile(Name,Status,Email,Date) values (@Name,@Status,@e,@CreatedAt)";
SqlCommand commm = new SqlCommand(inserQuery, conn);
commm.Parameters.AddWithValue("@Name", ProfileName.Text);
commm.Parameters.AddWithValue("@Status",TextBox1.Text);
commm.Parameters.AddWithValue("@e", Label1.Text);
commm.Parameters.AddWithValue("@CreatedAt", DateTime.Now);
commm.ExecuteNonQuery();
Label1.Text = Session["Email"].ToString();
}
但是在我发布一些状态后,我遇到了一些错误。
在这个网站上,我的新帖子显示在底部,最旧的帖子显示在顶部,但我希望新帖子显示在顶部,其他帖子逐渐从上到下,(考虑时间降序(
给我一个关于此代码的建议,以将这些设置为降序
SqlDataAdapter da = new SqlDataAdapter("Select * from PhotoStatusProfile WHERE Email = '" + Session["Email"].ToString() + "'", con);
谢谢
SqlDataAdapter
da = new SqlDataAdapter("Select * from PhotoStatusProfile WHERE Email = '" + Session["Email"].ToString(( +"' order by Date desc",con(;