ASP.NET InsertItemTemplate/DropDownList and CslaDataSource

ASP.NET InsertItemTemplate/DropDownList and CslaDataSource

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


pluc posted on Monday, November 05, 2007

Hello:

I have created a template field within a details view control.  The template field contains a drop down list that is bound to a Csla name/value list.  How do I expose the drop down list's selected value so that it is visible to my CslaDataSource object?  Thanks in advance for any feedback.

pluc replied on Thursday, November 08, 2007

Well, I have been unable to get any sort of binding expression to bubble the selected value of a drop down list-based template field within a details view up to my CslaDataSource object.  When my CslaDataSource object's InsertObject event handler fires, the event arg's Values property (a dictionary object) does not contain an entry for my template field.  All other non-template field values are present.  I'm not entirely sure why this is happening, but I can hook the ItemInserting event of my details view, retrieve the selected value of the template field's drop down list and add  it to the event arg's Values property like so:

DetailsView dtl = sender as DetailsView;
DropDownList lst = dtl.FindControl([List Name]) as DropDownList;
e.Values.Add([Property Name], lst.SelectedValue);


If I do this, then everything behaves properly within my CslaDataSource object's
InsertObject event handler.

If anyone knows of better way to accomplish this I would appreciate the feedback.  Otherwise, I hope this approach can help someone if they come across a similar situation.

Copyright (c) Marimer LLC