Guys,
Im having issues with binding a GridView and FormView to a single LLBGen data source control. The form view contains a Name property as a simple text box control and a user control. The user control is simple and just contains a text box and embedded list box.
I have an entity CodeTechnology which contains a collection of CodeTechnologyFileExtension objects. The FormView should be to the properties of a single CodeTechnology object. I can bind the Name property easily using ASPX such as
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' Columns="50"/>
However I can't get the binding working from the codeTechnology.CodeTechnologyFileExtension property so it binds the embedded list box in the user control to the values of each property in the CodeTechnologyFileExtensionCollection object.
The control is declared list this
<uc1:TransferTextToList ID="transferFileExtensionsToList" SourceTextBoxCaption="" runat="server" />
I have also created properties such as TargetListDataSource on the UserControl which simply wrap the DataSource on the embedded list box however I'm not sure how to use it in the calling page ASPX or code behind.
I can bind from the control to the data source i.e. when creating new records in the form view however I can't do it the other way around to load the data into the control. i.e. the PerformWork event handler on the data source has code
codeTechnology = uowElement[0].Entity as CodeTechnologyEntity;
// Obtain a list of file extensions in the target list
Controls_TransferTextBoxToListBoxControl transferFileExtensionsToList = CodeTechnologyFormView.Row.FindControl("transferFileExtensionsToList") as Controls_TransferTextBoxToListBoxControl;
ListItemCollection targetListFileExtensions = transferFileExtensionsToList.TargetListItems;
// Add each file extension to the CodeTechnologyEntity object
foreach (ListItem fileExtensionListItem in targetListFileExtensions)
{
CodeTechnologyFileExtensionEntity fileExtension = new CodeTechnologyFileExtensionEntity();
fileExtension.FileExtension = fileExtensionListItem.Value;
codeTechnology.CodeTechnologyFileExtension.Add(fileExtension);
}
codeTechnology.Save(true);
which simply uses the TargetListItems property to extract each embedded list box item from the user control and adds to the right LLBLGen entity property and calls Save.
Any help appreciated
Attachments
Filename |
File size |
Added on |
Approval |
FormViewCode.zip
|
4,925 |
26-Feb-2007 10:39.46 |
Approved |