tags:

views:

39

answers:

2

Here is my method that returns an IQueryable of Countries:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace InternationalShipments.Repository
{
    public class CountryRepository
    {
        ShipmentsEntities db = new ShipmentsEntities();

        public IQueryable<Country> FindAll()
        {
            return db.Countries;
        }

        public Country Get(int id)
        {
            return db.Countries.FirstOrDefault(x => x.ID == id);
        }

        public void Add(Country country)
        {
            db.Countries.AddObject(country);
        }

        public void Delete(Country country)
        {
            db.Countries.DeleteObject(country);
        }

        public void Save()
        {
            db.SaveChanges();
        }
    }
}

My intent is to show a form that lets you create new countries and on the same page, continue to display all countries in the DB. So if a user adds a new country, it should display in the table above.

Any guidance?

+2  A: 

Sergio,

The easiest way would be to use a Repeater. Using that you can easily bind your data to the control and create an HTML template for the output. If you want something with a little more power, you can try the DataGrid or Gridview

HTH,

Mike

Mike C
I went with a GridView. Just grdView.DataSource = repo.FindAll() and presto.
Serg
A: 

I think a Gridview using a Linq to SQL or SQL Datasource would fit the bill. I recall that the gridview can be customized to include an "add record" feature as well as the ability to edit returned records.

SidC
Every time someone recommends Gridview baby jesus cries...
Doug