Generating Columns in GridView ( C#, LINQ ) -


The situation is, I need to create a table in grid view such as:

- - ------- | Id --- | --- name-- | --1 / 2002-- | --2 / 2002-- | --1 / 2003-- | ........ | 2/2009 |
Cut 1 - |
Cut 2 - |



I have two tables in DB - I am receiving a simple query from client and order, SQL Data Contact ID id from LTIL and customer name

  var custInfo = Customer in DB Select the customer new {id = cust.Id, FullName = cust.FirstName + "" + cust.LastName} for the DataGrade Orders. Data source = custoinfo;  

And I need some clues, how to prepare that column in format T / year, where T indicates the first or second half of the year, and the orders of each customer

By now, I am trying to do something like this:

Order = grouped by db.Orders group ord ord.Ing_cust value = grouped Is done. Where (S = & gt; s.YearSession == session and & amp; amp; version == year). Select (a => new {cost = a.Cost}}) New {ID = Grouped. Choose the name, = custoinfo. Where (a = & gt; a.id == is grouped.). Select (j = & gt; j. Name). Single (), Cost = ExtensionLibrary.Sum (Cost, "\ n")};

(Only cost costs for each customer in that year's session are in cost)

And then I think walking in years and sessions and in any way Ask the question related to the column related to

  while (year & lt; = date time. Today. Year) {year ++; While (session and lieutenant; 2) {session ++; Data GridOders Preview. Columns Add (Session + "/" + year); Select Col.Add ((Session + "/" + year), Order (a => a.Cost) .toList ()); / * Cole Dictionary is & lt; String, list & lt; String & gt; & Gt; * /} Session = 0; }  

Here I have generated columns and I have an order in the dictionary where the key is the name of the column and the value is the order in that column, but I need some help in composing that column

The way I have seen it is to create a square, for which The properties that you want are examples,

  class CustOrders {public string CustName {get; Set;} public int order 20022-1 {received; Set;} public int order 2002-2-2 {received; Set;} ... public int order-2009-1 {get; Set;}}  

Then use the system. Windows.form. Binding source, call it calluses binding source and set your datasource in your new category list.

  from the list & lt; CustOrders & gt; MyListOfCustOrders = New List & lt; Custoders & gt; (); / * Code / / order order binding resource to populate my listofcustomers * .data source = myListOfCust order;  

In this case, you have to type the code to convert each result of your query results to the example of the custodians and store it in myListOfCustOrders.

Finally, the grid view data source must also be set:

  gridView1.DataSource = CustOrdsBindingSource;  

With this approach I see that the big problem is that you will have to change the custoder's class every year, unless there is some magic, after some time merge the classes in the class Can suggest to do / P>

In any way, I hope this gives you a start.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -