Basic databinding question

  • Thread starter Thread starter Richard Carpenter
  • Start date Start date
R

Richard Carpenter

Considering a typical scenario where the user is presented a list of
customers and, upon selecting one and clicking a button, they are then
presented with a new page depicting the orders for that customer and
the detail items for each order, what is the conventional (best) way to
"pass" the CustomerID from the first page to the second page and then
use it to only select the relevant orders to display as well as only
the relevant order detail items? Are session variables used for this?

Rich
 
Richard,

IMO, I would use a multi-view and just have a grid of each set of
detail on a different view. Tie each grid, Customer, Order, and Item
to a SqlDataSource to populate the grids. The Orders grid
SqlDataSource should have a Select parameter relying on the
SelectedValue of the Customers Grid (where the DataKeyName is
CustomerID). In kind, also do this for the relationship between the
Order Grid (again where the DataKeyName is OrderID) the Item Grid.

For easy to understand tutorials on all this, visit the www.asp.net
site.

I would not use Session variables in this case.

HTH,
Chris
 
chris said:
Richard,

IMO, I would use a multi-view and just have a grid of each set of
detail on a different view. Tie each grid, Customer, Order, and Item
to a SqlDataSource to populate the grids. The Orders grid
SqlDataSource should have a Select parameter relying on the
SelectedValue of the Customers Grid (where the DataKeyName is
CustomerID). In kind, also do this for the relationship between the
Order Grid (again where the DataKeyName is OrderID) the Item Grid.

For easy to understand tutorials on all this, visit the www.asp.net
site.

I would not use Session variables in this case.

I'm all for avoiding Session variables where possible, but in your
example how would entry of new orders or new detail items be
accomplished - by clicking an add button and entering the information
directly into the grid? While that provides a nice clean interface and
functionality from the development standpoint, I don't think it makes
for a very intuitive or user-friendly interface.

Perhaps it is due to the fact that I am coming from a windows
development mindset, but I've never been a fan of grid-based data
entry.

Any other ideas?

Rich
 
For the data entry part, you can use a form view for entering in new
data. As soon as the data is entered, you can bring them back to the
appropriate grid and call the GridView.Databind() method to refresh the
data.

If you want to make it like a WF environment, then you will probably
need to employ a bunch of jscript and utilize AJAX. The 2.0
environment does have some nice functionality built in though for the
GridView when it comes to AJAX, you can turn EnableAsyncCallback in the
control (I think) and then paging and sorting become a callback instead
of a postback.

One thing I just thought of is you could use the new CrossPagePostback
or Server.Transfer to transfer data from the previous page to the new
page. While they two functions are similar, it seems that the
crosspage postback actually processes the previous page again before
processing the new page. Server.Transfer() only passes the viewstate I
think. In either case you can pass controls or simple types via a
public property.

public int CustomerID
{
get{ return int.Parse(gridviewCustomer.SelectedValue);}
}

If you want to get more functionality then this, you may need to hire a
consultant, or build your own controls, or purchase a third party
control.

HTH,
Chris
 
Thanks a bunch. I had seen Server.Transfer() mentioned before, but
never understood what it was for. After a little digging, I think that
is the way to go.

Thanks again.
Rich
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top