Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > GridView made by different datasources

Reply
Thread Tools

GridView made by different datasources

 
 
tsaprout tsaprout is offline
Junior Member
Join Date: Jun 2008
Posts: 7
 
      07-30-2008
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
filling the same gridview wid from different datasources Shanksluvsuall ASP .Net 0 03-14-2008 11:27 AM
Best approach to use different datasources - ? alexandis@gmail.com ASP .Net 10 11-06-2007 03:31 PM
Gridview with changing Datasources in code - some things don't work jobs ASP .Net 0 11-21-2006 05:05 PM
gridview switching datasources in the codebehind. ... Delete no longer happens. jobs ASP .Net 3 11-21-2006 04:52 PM
Efficiently comparing 2 datasets from different datasources Elliot M. Rodriguez ASP .Net 0 07-06-2004 02:38 PM



Advertisments