Dataset from a DB, Sorting and Showing Contents
-
I have a database with the columns of tblNewsID, Time, Date, News, User. What I am trying to do is to sort the data by the Date column and then pull each of the rows data into strings. With the code below I get the entries pulled out but not in any sorted order, they just come out as they were entered. I have tried all the help articles and I think that I am just very confused. In advance I appriciate any help that anyone can give me. conRCDB.Open(); cmdtblNews.Fill(dsNews); this.DataBind(); dsNews.tblNews.DefaultView.Sort = "Date ASC"; foreach (dsNews.tblNewsRow objNews in dsNews.tblNews) { string strTime = objNews.Time.ToShortTimeString(); string strDate = objNews.Date.ToLongDateString(); string strNews = objNews.News.ToString(); string strUser = objNews.User.ToString(); Label lblNews = new Label(); lblNews.Text = "" + strTime + ""; lblNews.Text += " " + strDate + ""; lblNews.Text += "
" + strNews + ""; lblNews.Text += "
-" + strUser + ""; panSiteNews.Controls.Add(lblNews); }