Link to home
Start Free TrialLog in
Avatar of RedXavier2k4
RedXavier2k4

asked on

How can I bound this gridview with this List<> code?

How can I bound this gridview with this List<> code? I want to use the '<asp:ObjectDataSource ID' to bind the data with little to no code behind. Thanks

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

namespace Psc.EmployeeAdmin.wrkStation
{
    public class EmployeeWorkStation
    {
        private Admin.iAdmin _ws;
        
        public List<Admin.vwEmployee> GetEmployees(out string strReturnMessage, int tSiteID, bool blInActive)
        {
            List<Admin.vwEmployee> EmployeeAdminList = new List<Admin.vwEmployee>();
			
            try
            {
                EmployeeAdminList = this._ws.GetEmployees(out strReturnMessage, tSiteID, blInActive);
            }
            catch (Exception ex)
            {
                strReturnMessage = ex.Message.ToString();
            }

            return EmployeeAdminList;
        }
        
    }
}

Open in new window


<asp:GridView ID="grdEmpAdmin" runat="server">
	<Columns>
		<asp:BoundField DataField = "FirstName" HeaderText = "First Name" />
		<asp:BoundField DataField = "MiddleName" HeaderText = "Middle Name" />
		<asp:BoundField DataField = "LastName" HeaderText = "Last Name" />
		<asp:BoundField DataField = "HireDate" HeaderText = "Hire Date" />
		<asp:BoundField DataField = "BirthDate" HeaderText = "Birth Date" />
		<asp:BoundField DataField = "TerminationDate" HeaderText = "Termination Date" />
	</Columns>
</asp:GridView>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RedXavier2k4
RedXavier2k4

ASKER

Thanks the ObjectDataSource was what I was looking for.