How do I design a method to list a certain row at the top of gridview table?
I have a gridview of jobTable which has a checkbox "IsTop" (a bit column inside jobTable), which means they will be listed at the top in the list of "latest job postings". Which is the best way to implement this function?
My idea is to ensure if 1 row "IsTop" checked, all other chec开发者_运维技巧kBox assocated with other rows will become invisible, and find that JobID as the startRowIndex. But how do I write that code?
Why not write a LINQ query and orderby IsTop descending
? The results should be in the order you need then when you bind.
BookstoreDataContext db = new BookstoreDataContext();
GridView1.DataSource = db.Books.OrderBy(b => m.Title);
GridView1.DataBind();
if(CheckBox_IsTop.Checked==true)
Update IsTop in "BookLists" Where="BookID == @BookID1"
精彩评论