Note that there are some explanatory texts on larger screens.

plurals
  1. POCombine data from multiple sources, display in ASP.Net GridView
    primarykey
    data
    text
    <p>I am writing a currency converting module for one of our applications. I have a list of products, a list of currencies we are interested in seeing prices for, and a list of currency rates. I want the user to be able to select which currencies from the list they see in the GridView.</p> <p>I also want to be able to amend my list of currencies and include a new currency, without having to make additional changes to this module. So my GridView display has to be <em>dynamic</em>.</p> <p>Essentially I am planning on ending up with a GridView that has the following columns:</p> <p><strong>Part No - Description - USD Price - AUD Price - GBP Price</strong></p> <p>The USD price would be static as it's our base currency, the AUD and GBP are user selected and could have potentially any number of currencies listed.</p> <p>I would normally use a DataSet and DataTables for this work, but I am sure there is a "better" way to do it using System.Collections.Generics.</p> <p>Right now I have all of the data I need in List collections, but there does not seem to be a way to define how these collections relate to each other, or combine these collections into one so it can be bound to a GridView.</p> <p>Should I be looking at something other than List to achieve this or do I need to go back to my original approach of a DataSet and DataTables.</p> <p>Thanks!</p> <p>******UPDATE / SOME CODE******</p> <p>OK, someone asked for some code, so I will explain a little bit more about what I have setup so far.</p> <ol> <li><p>List of Products &amp; Currencies - These come from an SQL DB via LINQ, so they can be any of the System.Collections.Generics objects, e.g. List, IEnumerable etc.</p></li> <li><p>Currency Rates - These I am pulling from the European Bank public XML file. I download the file, strip the data I need out of it and currently store that as a List object.</p></li> </ol> <p>I <em>could</em> store the currency rates in the database table as well, but then I have to have some sort of background process that goes and updates the rates each day. This way the rates only get updated when someone accesses the report function (which is only going to happen occasionally). So I would rather grab the latest rates "on demand".</p> <p>What I know I need to end up with is some object that has the following structure:</p> <p><strong>PartNo - Description - Base Price - Currency Price 1, Currency Price 2, Currency Price 3</strong></p> <p>Where the number of Currency Prices is <em>undefined</em>, as it's based on what currencies the user wants the report to display.</p> <p>It's the undefined part that I am struggling with, essentially how can I create a structured object, that I don't know the complete structure of until runtime ?</p> <p>Hope this makes more sense / helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload