Complex databinding

C

Craig Buchanan

I have an class, named MessageTemplate, that has three properties: Name,
Description, and Tokens. The Name and Description properties are strings.
The Tokens property, however, is a KeyedCollection of the Token class. The
Token class has two string properties: Name and Pattern.

I have a third class, named MessageTemplateAdapter, that manages the
MessageTemplate's CRUD processes to a single XML file. This works
correctly.

I am in the midst of creating a form to add/edit the MessageTemplate class.
I've created an ObjectDataSource to tie the MessageTemplateAdapter to a
DetailsView. This works as expected for the Name and Description
properties.

I would like to bind the MessageTemplate's Tokens collection to a GridView
on the same form, then use the GridView to add/edit each Token. Moreover, I
want the DetailsView's Insert/Update methods to save the collection's data
along w/ the Name and Description properties. Essentially, I want to save
the parent and the child together.

While I'm able to bind the Tokens collection to GridView in the
DetailsView's DataBound event (the DetailView's DataItem), I haven't been
able to get the GridView's Edit/Delete/Insert to work.

Does anyone have a recommendation on how to handle complex data binding like
this?

Thanks in advance,

Craig
 
M

Munna

I have an class, named MessageTemplate, that has three properties: Name,
Description, and Tokens. The Name and Description properties are strings.
The Tokens property, however, is a KeyedCollection of the Token class. The
Token class has two string properties: Name and Pattern.

I have a third class, named MessageTemplateAdapter, that manages the
MessageTemplate's CRUD processes to a single XML file. This works
correctly.

I am in the midst of creating a form to add/edit the MessageTemplate class.
I've created an ObjectDataSource to tie the MessageTemplateAdapter to a
DetailsView. This works as expected for the Name and Description
properties.

I would like to bind the MessageTemplate's Tokens collection to a GridView
on the same form, then use the GridView to add/edit each Token. Moreover, I
want the DetailsView's Insert/Update methods to save the collection's data
along w/ the Name and Description properties. Essentially, I want to save
the parent and the child together.

While I'm able to bind the Tokens collection to GridView in the
DetailsView's DataBound event (the DetailView's DataItem), I haven't been
able to get the GridView's Edit/Delete/Insert to work.

Does anyone have a recommendation on how to handle complex data binding like
this?

Thanks in advance,

Craig

Hi,

this is a simple article to show master detail view with detail view
and grid view. which expain the view
http://www.asp.net/learn/data-access/tutorial-10-vb.aspx
i guess your main problem is create a crud module for you class
template.
I have few simple trik to help you since i have already worked on some
thing like that

1. create a simple user control consisting with detail view and a grid
view.
[grid view for tokens and detail view for messagetemple name and
description or perhaps you can create simple two textbox and labels
instead of detail view to make things easy]
2. implement mode for the user control (create,read,update,delete)
3. make a datasource property in the control
4. implement command button in the user control

5. when you add a new MessageTemplate start with null message
template.
upon user command create messagetemple class instance and fill the
class with data
and then save in database using your store procedure or what you have
used.

6. when updating/reading set the datasource property of the
usercontrol and then in on load the controls's data from the class

Thats it.

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top