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

RedXavier2k4Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSoftware EngineerCommented:
Your ODS should look like
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            DataObjectTypeName="Admin.vwEmployee" 
            SelectMethod="GetEmployees" TypeName="EmployeeWorkStation">
        <SelectParameters>
            <asp:ControlParameter ControlID="grdEmpAdmin"
                Name="strReturnMessage" Direction="Output" Type="Int32" />
            <asp:ControlParameter ControlID="grdEmpAdmin"
                Name="tSiteID" Type="Int32" />
              <asp:ControlParameter ControlID="grdEmpAdmin"
                Name="blInActive" Type="Boolean" />
        </SelectParameters>
        </asp:ObjectDataSource>

Open in new window


There are other methods you can define: DeleteMethod, InsertMethod, etc. For more info check:
http://msdn.microsoft.com/en-us/library/57hkzhy5.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RedXavier2k4Author Commented:
Thanks the ObjectDataSource was what I was looking for.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.