我已经在元数据的帮助下创建了一个用于固定新闻项目的复选框,只是不能将最后固定的项目保留在列表的最顶部,这是我的代码:
using (conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=""C:\Users\BOB\Documents\Visual Studio 2012\Projects\Login\Login\Student_Marks.mdf"";Integrated Security=True"))//; this was the issue
{
using (adap = new SqlDataAdapter("select * from tbl_Students_Marks", conn))
{
DataSet das = new DataSet();
adap.Fill(das);
dataGridView1.DataSource = das.Tables[0];//this must be das not ds
}
}
答案 0 :(得分:0)
终于找到了解决方案。这是一个适合我的代码:
$args_meta = array(
'post_type' => 'news',
'posts_per_page' => -1,
'meta_key' => 'pinned_news_item',
'orderby' => 'modified',
'order' => 'DESC',
'ignore_sticky_posts' => '1'
);
答案 1 :(得分:0)
Please try by editing your query:
$args = array(
'post_type' => 'news',
'posts_per_page' => -1,
meta_query' => array(
array(
'key' => 'pinned_news_item',
'value' => '1',
)
),
'order' => 'DESC',
'orderby' => $today,
);
Reference: http://www.happiweb.net/2015/05/code-wordpress-thuong-dung.html