GridView made by different datasources

Discussion in '.NET' started by tsaprout, Jul 30, 2008.

  1. tsaprout

    tsaprout

    Joined:
    Jun 4, 2008
    Messages:
    7
    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!
    tsaprout, Jul 30, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elliot M. Rodriguez
    Replies:
    0
    Views:
    350
    Elliot M. Rodriguez
    Jul 6, 2004
  2. jobs
    Replies:
    3
    Views:
    618
  3. jobs
    Replies:
    0
    Views:
    364
  4. alexandis@gmail.com

    Best approach to use different datasources - ?

    alexandis@gmail.com, Nov 2, 2007, in forum: ASP .Net
    Replies:
    10
    Views:
    525
    Mark Rae [MVP]
    Nov 6, 2007
  5. Shanksluvsuall
    Replies:
    0
    Views:
    362
    Shanksluvsuall
    Mar 14, 2008
Loading...

Share This Page