private void RefreshGridView() { tblBook = adpBook.GetData(); // get the datatable grdBook.DataSource = tblBook; grdBook.DataBind(); tblAuthor = adpAuthor.GetData(); tblCat = adpCat.GetData(); tblPub = adpPub.GetData(); lstAuthor.DataSource = tblAuthor; lstAuthor.DataTextField = tblAuthor.AuthorNameColumn.ToString(); lstAuthor.DataValueField = tblAuthor.AuthorIdColumn.ToString(); lstAuthor.DataBind(); lstAuthor.Items.Insert(0, new ListItem("Add Author", "-1")); //lstAuthor.SelectedIndex = 1; lstPub.DataSource = tblPub; lstPub.DataTextField = tblPub.PublisherNameColumn.ToString(); lstPub.DataValueField = tblPub.PublisherIdColumn.ToString(); lstPub.DataBind(); lstPub.Items.Insert(0, new ListItem("Add Publisher", "-1")); //lstPub.SelectedIndex = 1; lstCat.DataSource = tblCat; lstCat.DataTextField = tblCat.CategoryNameColumn.ToString(); lstCat.DataValueField = tblCat.CategoryIdColumn.ToString(); lstCat.DataBind(); lstCat.Items.Insert(0, new ListItem("Add Category", "-1")); //lstCat.SelectedIndex = 1; }
/// <summary> /// Goes through all rows in Author table and creates a list of authors /// </summary> /// <returns>Returns list of authors</returns> public List <Author> getAuthors() { List <Author> authors = new List <Author>(); foreach (AuthorRow row in _authorAdapter.GetData().Rows) { authors.Add( new Author(row.AuthorId, row.Name, row.DOB, row.Country) ); } return(authors); }