views:

29

answers:

1

not sure of what to put as the title here, but basically I am using subsonic in asp.net forms C# and I have an instance where I need to loop through a recordset and for each one call the Database to get specific information from a view about that record.

in this instance it is a venue, loop through and for each venue I show there spend and there budget, but I am at a loss as to how I can say use a gridview, execute more code on each row and then add more columns to that row.

many thanks for all advise

:-)

just as an update i have been playing with the idea of something like this:

    DataSet ds = new DataSet();
    ds.Tables.Add(LinqToDataTable(club.All().Where(x => x.level == 1)));
    ds.Tables.Add(LinqToDataTable(ViewBudgetSpend.All().Where(x => x.periodfrom == curperiod)));

    DataRelation relation = new DataRelation("budgets",ds.Tables[0].Columns["clubId"],ds.Tables[1].Columns["clubid"]);
    ds.Relations.Add(relation);

still working this out though.

+1  A: 

Hey,

That is a good idea, but even better, just make one big table, not a relation. GridView works better that way, with a flat tabular data source, so you are essentially denormalizing the results into one table and binding. This works great as you can manipulate the table by adding columns, then looping through the rows and updating with your new values.

Alternatively, you can work after the fact, by using the GridView RowDataBound, and manually passing data to controls in a TemplateField column.

HTH,

Brian

Brian
yes have thought of just creating a flat datatable from scratch and adding my own columns but never done this before and every time you search google with a hash you now get some stupid redirect page that doesn't allow you to go back, was thinking of actually using the relation still as not every user has a budget and spend so need to run from the relation so i can tie in better and faster... nice idea mind it does seem the most logical solution :-) thanks
minus4
The GridView doesn't automatically bind relations though, so you would have to programmably display the data from the related table... might be a workaround with a DataView or something else...
Brian
yeah good point this is something for a monday i think :-) lol anyway thanks for the advise will tick it off for ya
minus4