void PopulateRow(NietoYostenDbDataContext db, int row) { Table<HomePageArticle> HomePageArticles = db.GetTable<HomePageArticle>(); HomePageArticle h = HomePageArticles.Single(q => q.Position == row); Control mainContent = Page.Master.FindControl("MainContent"); ((CheckBox)mainContent.FindControl("chkShow" + row)).Checked = h.Enabled; int sectionId1 = h.Article.SectionId; ((DropDownList)mainContent.FindControl("ddlSection" + row)).SelectedValue = sectionId1.ToString(); DropDownList ddlArticle = (DropDownList)mainContent.FindControl("ddlArticle" + row); PopulateArticleList(db, ddlArticle, sectionId1); ddlArticle.SelectedValue = h.ArticleId.ToString(); }
void PopulateArticleList(NietoYostenDbDataContext db, DropDownList ddl, int sectionId) { Table<Article> Article = db.GetTable<Article>(); var q = from a in Article where a.SectionId == sectionId orderby a.DateCreated descending select a; ddl.Items.Clear(); foreach (var article in q) { string publishedStatus = article.Published ? "" : "(Unpublished)"; ListItem item = new ListItem(article.Title + " " + publishedStatus, article.ArticleId.ToString()); ddl.Items.Add(item); } }