private void FillAuthorList()
    {
        DataTable newTable = AuthorAccess.GetAllAuthorNames();

        foreach (DataRow row in newTable.Rows)
        {
            ListItem newItem = new ListItem();
            newItem.Text  = row["au_lname"] + ", " + row["au_fname"];
            newItem.Value = row["au_id"].ToString();
            lstAuthor.Items.Add(newItem);
        }
    }
Пример #2
0
    private void FillAuthorList()
    {
        //This method should populate the lstAuthor DropDownList with the authors in the pubs database
        //Author names are shown as the text for each ListItem and author IDs are stored as the values
        //See Pages 451-452
        lstAuthor.Items.Clear();

        DataTable table = AuthorAccess.GetAllAuthorNames();


        foreach (DataRow row in table.Rows)
        {
            ListItem newItem = new ListItem();
            newItem.Text  = row["au_lname"] + "," + row["au_fname"];
            newItem.Value = row["au_id"].ToString();
            lstAuthor.Items.Add(newItem);
        }
    }