Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am trying to populate a data-grid/ and or table by clicking a button from my webpage. At the moment I only learned how to bind information. Can someone please direct me in the right direction. I have made my sql connection so far and added the button to the page. I've searched online trying to get examples of this and came up short.

My Query generates the following columns: (Stored Procedure)

LoginID---JobTitle--- Name--- GroupName ---Gender ---Hiredate

And I would like for the columns to match what's on my default.aspx page ASPX.CS Behind code

    protected void Getmployee_Click(object sender, EventArgs e)
    {
        Getmployee_Click = Getmployee;
        GridView1.DataSource = Getmployee;
        GridView1.DataBound();

    }

Here is my Class: //Its not perfect

using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;

namespace Test1
{
public class GetEmployee
{
    private string LoginID;
    private string JobTitle;
    private string Name;
    private string GroupName;
    private string gender;
    private DateTime HireDate;


}
public GetEmployee()
{

}

  public GetEmployee( string LoginID,string JobTitle,
     string Name,string GroupName,string gender,DateTime HireDate)
{
this.LoginID = LoginID;
this.JobTitle = JobTitle;
this.Name = Name;
this.GroupName = GroupName;
this.gender = gender;
this.HireDate = HireDate;
}

public string LoginID {get{return this.LoginID}}
public string JobTitle {get{return this.JobTitle}}
public string Name {get{return this.Name}}
public string GroupName {get{return this.GroupName}}
public string gender {get{return this.gender}}
public DateTime  HireDate {get{return this.HireDate}}
}

Here's my connection class

using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;

namespace Test1
{
internal sealed  class ConnectionManager
{
    public static SqlConnection GetConnection() 
    {
        string connectionString = ConfigurationManager.ConnectionStrings ["AdventureWorks2008R2"].ConnectionString;

        SqlConnection connection = new SqlConnection(connectionString);

        connection.Open();
        return connection;
    }
  }
}
share|improve this question

closed as off topic by Yannis Rizos Apr 15 at 0:07

Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.