GridView binds multiple data sources with the same format (data query merge)

Source: Internet
Author: User

When you do a project, you need to display the first few data from different groups in the same GridView

Several technical points:

1, data grouping, this method does not use GROUP by

2. Several query merge bindings with the same result format

3, take the query results before or after a number of data

public int Bindliftdata ()

{

int count = 0;

using (mysqlconnection conn = new Mysqlconnection (dbserver))

{

Frddata db = new Frddata (conn);

list<int> ids = new list<int> ();

var item = from I in db. Items

Join P in DB. Progs on I.progid equals p.id

where p.state = = 1 && i.type = = "Lift"

Select New {i.id};

bool IsFirst = true;

int FirstID = 0;

foreach (var i in item)

{

if (IsFirst)

{

FirstID = i.id;

IsFirst = false;

}

Else

Ids. ADD (i.id);

}

var q = (from I in DB. Items

Join L in DB. Lifts on i.id equals l.itemid

where i.id = = FirstID

L.id Descending

Select New {i.id, I.name, L.angle, I.stole, L.lift}). Take (3). ToList ();

foreach (var x in IDs)

{

var r = (from I in DB. Items

Join L in DB. Lifts on i.id equals l.itemid

where i.id = = X

L.id Descending

Select New {i.id, I.name, L.angle, I.stole, L.lift}). Take (3). ToList ();

Q.addrange (R);

}

Gvlift.datasource = q;

Count = Q.count;

}

return count;

}

GridView binds multiple data sources with the same format (data query merge)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.