OT: Another Web Design Question

OT: Another Web Design Question

Old forum URL: forums.lhotka.net/forums/t/1219.aspx


MadGerbil posted on Thursday, September 14, 2006

Greetings:

I've a collection that I like to display on a datagrid.  There is no problem databinding it to a CSLA datasource and doing the update, deleted, insert.   However, for the updates I'd like to go to a separate 'view' (like form view or multi-view) and view the editing item in more detail.

Is there a databound way to do this?

The example in the book has stuff bound to a datagrid with the edit view just making the labels into textboxes for editing - which works when you have only 3 columns - but what about cases where your object would have 20 columns and you want to display only 3 in the datagrid with the other 17 being editable in a different view (such as edit view)?

I've tried formview with a nested gridview in the <itemtemplate> but I don't know how to get the selected item up in the <edittemplate> -- or if there is a better control for this.

MadGerbil replied on Thursday, September 14, 2006

One possibility, and the one I'll likely go with is that with a multi-view I can still get to both a GridView and a DetailsView in code without messing around with FindControl.  I can then change the view programatically and bind the controls to either the parent collection or the child object, respectively.

I think.

I'll let ya'll know.

 

MadGerbil replied on Thursday, September 14, 2006

No can do.

Even though I can get the ID of the child object from the DataGrid collection there is no way for me to bind a DetailsView to a single child object and show it by switching to a different view in the MultiView.

I'm missing something -  a simple Master/Detail list in two separate views on the same page shouldn't be this difficult.

RockfordLhotka replied on Thursday, September 14, 2006

Wouldn't you use a ReadOnlyListBase-derived list for the grid in DisplayView, and bind that to a CslaDataSource? And then in EditView you'd have a different CslaDataSource to get at a BusinessBase-derived object for editing?

MadGerbil replied on Friday, September 15, 2006

Yeah, I suppose I could do that.

I was hoping since I had the object in memory (in a collection) that I wouldn't have to fetch it from the database to edit a single object - I thought there might be a way to display the single object that I already have in the collection.   That is how I'd handle in a windows form - so I might not have my mind in the web form world quite yet.

So I could get the ID of the selected object, fetch teh object from teh database as part of a 2nd CslaDataSource, and display that -- is that what you are suggesting?

DansDreams replied on Friday, September 15, 2006

I'm somewhat of a newbie when it comes to asp.net, but wouldn't you need to persist the retrieved collection on the server anyway to accomplish that?  I mean, you don't really have a collection of those fully hydrated objects back at the client do you?  So, if I'm thinking correctly you're not really saving anything by trying to avoid the round trip and database read.

If you want to implement that kind of interface as a rule then you might want to dig into the Atlas/Ajax or Web Parts capabilities, with the general idea being that you only need to go back to the server for the portion of the web form that will actually change.

MadGerbil replied on Friday, September 15, 2006

IT WORKS!

IT WORKS!

When I hit the 'edit' button on the datagrid I stick the ID of the single object into a variable on the webpage and then switch view.  When I switch view the Select for the single object data source is fired, I then use the saved ID to grab the object out of the collection, assign it to the datasource, and display the view.  This without an additional roundtrip.

I've been look for an answer like this for 2 days - I just knew I was missing something.

wOOt  <------ happy developer noise.

ChristianPena replied on Friday, September 15, 2006

Where are you caching your collection?

MadGerbil replied on Friday, September 15, 2006

I'm caching the collection in a session variable.

RockfordLhotka replied on Friday, September 15, 2006

I am not saying you need to get the object from the database - just that you need another CslaDataSource control.
 
If you can write code in your page (probably in the SelectObject event handler for the second control) to find the existing in-memory object selected by the user, then that's a great option!
 
Or, if you need to, you can get the id of the selected object and fetch that specific object - which ever one works.
 
Rocky

So I could get the ID of the selected object, fetch teh object from teh database as part of a 2nd CslaDataSource, and display that -- is that what you are suggesting?

Copyright (c) Marimer LLC