GridView made by different datasources

Joined
Jun 4, 2008
Messages
7
Reaction score
0
Hi everyone,

I'm trying to create a GridView with the following criteria:

1. I need to have 5 fields of personal info of every employee (DB TABLE : Usernames - FIELDS: name, username, e-mail, contract, isIT)

2. I need 2 fields which are the start month and year of each employee (DB TABLE: Employment - FIELDS: month, year)

3. I need 2 fields which are the last month and year of each employee (DB TABLE: Employment - FIELDS: month, year)



Every row (which represents info about each employee) of the GridView should be consisted of all the above fields.



So far I succeeded to have no.1 working in the following way:

QueryCommand smd = new QueryCommand(sql);

ds = DataService.GetDataSet(smd);

GridView1.DataSource = ds;

GridView1.DataBind();




It's quite hard for me to create such a complicated query which will give me all the above together (1, 2 and 3).

(If somebody is comfortable with SQL maybe he/she can help me out).

If not, is there a way to append more columns in my already existing GridView using another sql statement?

Can you think of any other ways?



My GridView is sortable:

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
String SOS = Session["mySql"].ToString();

string sortExpression = (string)Session["SortExp"];

string sortDirection = (string)Session["SortDir"];
if (sortExpression != e.SortExpression)
{

sortExpression = e.SortExpression;
sortDirection = "asc";

}

else
{
if (sortDirection == "asc")

sortDirection = "desc";

else
sortDirection = "asc";

}
Session["SortExp"] = sortExpression; Session["SortDir"] = sortDirection;

QueryCommand smd = new QueryCommand(SOS);

ds = DataService.GetDataSet(smd);


DataView dv = new DataView(ds.Tables[0]);
dv.Sort = sortExpression + " " + sortDirection;

GridView1.DataSource = dv;

GridView1.DataBind();
}



Will it still be sortable if I add more columns in it?

Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top