• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1102
  • Last Modified:

I have to create a GridView from a List<>

I have to create a GridView from a List that hold data from an SQL Server table. The. A web service is being using by I think LINQ, and is added to a List<>. This is the code I have so far in the EmployeeManager. How can I populate my GridView with this List<> data. The page load is from EmployeeManager.aspx.cs and my GridView is in EmployeeManager.aspx
I need help like yesterday, thanks

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

namespace Psc.Employees.EAdmin
    public class EmployeesAdmin
       private Admin.iAdmin _ws;

       public List<Admin.vwEmployees> GetEmployees(out string x, int i, bool blDisabled)
           return _ws.GetEmployees(out x, i, blDisabled);

Open in new window

protected void Page_Load(object sender, EventArgs e)
	//Create Data Source from List

Open in new window

2 Solutions
Ioannis ParaskevopoulosCommented:
Have you tried something like

GridView.Datasource = GetEmployees(args);

Open in new window

Miguel OzSoftware EngineerCommented:
Actually you need both markup and code behind changes as shown here

In the markup you specify in the Columns elements the BoundFields that are loaded from your object property.
In the code behind you called your web service method to assign the returning list to GridView1.Datasource  and then call GridView1.DataBind()
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now