I'm following your tutorial inside web forms and chapter "continuing with EF" to build a similar application and specifically I would like to use objectdatasource instead of Entitydatasource.
The only difference in my project is that I want to use a ForView instead of DetailsView to edit and insert new data.
The problem I have is in the use of the DynamicField because they seems to be not simply supported.
After a lot of search I found that:
1) Using FormView it's not available a sentence like:
Well, when I click the button in the FormView to enter in "edit" mode I receive the following error in the line I added in the global.asax showed above:
Errore di run-time di Microsoft JScript: Sys.WebForms.PageRequestManagerServerErrorException: Could not determine a MetaTable. A MetaTable could not be determined for the data source 'ODSClidet' and one could not be inferred from the request URL. Make sure
that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute.
How can I add this metatable to my objectdatasource?
I'm sure I used DynamicData in the EditTemplate of the FormView instead of the BoundField... by the way, I'd like to use the DynamicData just for Validation and formatting purposes for now, so I didn't replace all the fileds inside the FormView with a DynamicData and
I have some fields in "BoundField" and someone else in "DynamicData"... could be this a problem?
If this is not a problem, I think your question 1 is my problem. Can you explain me how the partial mode can be mapped to the existing table or how can I check this is done correctly?
I used in the Global.asax the following instruction
DefaultModel.RegisterContext(typeof(GIVDBcon), new ContextConfiguration() { ScaffoldAllTables = false });
and I'm perfectly sure that GIVDBcon is the right name of my context object.
I think I'm not ready for this... I tried to read the article an applied some changes but the result is still an error message.
This is what I did:
I downloaded from codeplex the source to generate the Microsoft.Web.DynamicData.dll and I built it.
I added to my project the extensions provided by this dll and I used the DynamicObjectDataSource instead of ObjectDataSource as the source of my FormView supposing it would be the only change I need.
If I run the application now the error message is that it doesn't find the folder "DynamicData/FieldTemplate" in fact this path doesn't exist in my project!!
I know that if I build a new project in VisualStudio 2010 selecting the web application for entities and DynamicData a lot of folders will be created automatically like "DynamicData" and also the subfolders "FieldTemplate" or "CustomPages" and so on by my
application is not born in this way and I don't want to convert it completely in this type of project.
I just needed to add the DynamicControl instead of the BoundControl to my application to exploit the validation and formatting features of these type of data.
The problem is that following the great tutorial "Continuing with EF" on this site, it seemed to be very simple using GRIDVIEW and DETAILSVIEW controls to use the DynamicControl instead it seems to be a hell using FORMVIEW. Using GridView you can simply
add a class with few lines for the [MetadataType(typeof(DepartmentMetaData))] and that's all. I don't want to add too much complexity to my project just for validation and formatting.
I read also this article but I didn't find a solution.
wmartin
Member
24 Points
20 Posts
Metatable and formview
Feb 05, 2012 10:36 PM|LINK
I'm following your tutorial inside web forms and chapter "continuing with EF" to build a similar application and specifically I would like to use objectdatasource instead of Entitydatasource.
The only difference in my project is that I want to use a ForView instead of DetailsView to edit and insert new data.
The problem I have is in the use of the DynamicField because they seems to be not simply supported.
After a lot of search I found that:
1) Using FormView it's not available a sentence like:
DepartmentsGridView.EnableDynamicData(typeof(Department));
in the page_init.
but it seems to be that I can replace it using the following few lines:
<asp:DynamicDataManager ID="DDMCliente" runat="server" AutoLoadForeignKeys="true">
<DataControls>
<asp:DataControlReference ControlID="FVcliente" />
</DataControls>
</asp:DynamicDataManager>
where FVCliente is the ID of my formview
also I added in the Global.asax the following line:
DefaultModel.RegisterContext(typeof(GIVDBcon), new ContextConfiguration() { ScaffoldAllTables = false });
where GIVDBcon is the name of my ObjectContext
FVcliente has the following Objectdatasource
<asp:ObjectDataSource ID="ODSClidet" runat="server"
TypeName="Giv2010EF.BLL.ClientiBL"
DataObjectTypeName="Giv2010EF.DAL.clienti"
SelectMethod="GetBynumcli" UpdateMethod="UpdateCliente" InsertMethod="InsertCliente" DeleteMethod="DeleteCliente"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="orig{0}">
<SelectParameters>
<asp:ControlParameter ControlID="LVClienti" Name="numcli" PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>
and inside the same folder of the edmx file, I have a class "clienti" similar to "departments" of your tutorial where I wrote the following:
[MetadataType(typeof(clientiMetaData))]
public partial class clienti{}
[ScaffoldTable(true)]
public class clientiMetaData
{
[DataType(DataType.Text)]
[StringLength(5, ErrorMessage = "Lunghezza massima 5 caratteri")]
public String COGNOME { get; set; }
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
public DateTime NASCITA { get; set; }
}
Well, when I click the button in the FormView to enter in "edit" mode I receive the following error in the line I added in the global.asax showed above:
Errore di run-time di Microsoft JScript: Sys.WebForms.PageRequestManagerServerErrorException: Could not determine a MetaTable. A MetaTable could not be determined for the data source 'ODSClidet' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute.
How can I add this metatable to my objectdatasource?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Metatable and formview
Feb 07, 2012 01:12 AM|LINK
Hello:)
1)Please make sure that your partial model has been mapped to the existing tables successfully,and the class name (case-sentsitive)is right。
2)Then make sure that you are using asp:DynamicData control instead of any other ones such as asp:BoundField……。
Reguards!
wmartin
Member
24 Points
20 Posts
Re: Metatable and formview
Feb 07, 2012 08:19 AM|LINK
Thanks for your help!
I'm sure I used DynamicData in the EditTemplate of the FormView instead of the BoundField... by the way, I'd like to use the DynamicData just for Validation and formatting purposes for now, so I didn't replace all the fileds inside the FormView with a DynamicData and I have some fields in "BoundField" and someone else in "DynamicData"... could be this a problem?
If this is not a problem, I think your question 1 is my problem. Can you explain me how the partial mode can be mapped to the existing table or how can I check this is done correctly?
I used in the Global.asax the following instruction
DefaultModel.RegisterContext(typeof(GIVDBcon), new ContextConfiguration() { ScaffoldAllTables = false });
and I'm perfectly sure that GIVDBcon is the right name of my context object.
thanks
sjnaughton
All-Star
27320 Points
5459 Posts
MVP
Re: Metatable and formview
Feb 07, 2012 05:01 PM|LINK
See David Ebbos article here Using ASP.NET Dynamic Data with ObjectDataSource
Always seeking an elegant solution.
wmartin
Member
24 Points
20 Posts
Re: Metatable and formview
Feb 07, 2012 05:31 PM|LINK
This link seems to be no more valid...
wmartin
Member
24 Points
20 Posts
Re: Metatable and formview
Feb 07, 2012 05:32 PM|LINK
ok, I found it here...
http://blogs.msdn.com/b/davidebb/archive/2008/06/18/using-asp-net-dynamic-data-with-objectdatasource.aspx
I'll try to read it
thanks
sjnaughton
All-Star
27320 Points
5459 Posts
MVP
Re: Metatable and formview
Feb 07, 2012 06:27 PM|LINK
yep that happens every time you past a link in to the forum I should know by now :)
Always seeking an elegant solution.
wmartin
Member
24 Points
20 Posts
Re: Metatable and formview
Feb 07, 2012 09:14 PM|LINK
I think I'm not ready for this... I tried to read the article an applied some changes but the result is still an error message.
This is what I did:
I downloaded from codeplex the source to generate the Microsoft.Web.DynamicData.dll and I built it.
I added to my project the extensions provided by this dll and I used the DynamicObjectDataSource instead of ObjectDataSource as the source of my FormView supposing it would be the only change I need.
If I run the application now the error message is that it doesn't find the folder "DynamicData/FieldTemplate" in fact this path doesn't exist in my project!!
I know that if I build a new project in VisualStudio 2010 selecting the web application for entities and DynamicData a lot of folders will be created automatically like "DynamicData" and also the subfolders "FieldTemplate" or "CustomPages" and so on by my application is not born in this way and I don't want to convert it completely in this type of project.
I just needed to add the DynamicControl instead of the BoundControl to my application to exploit the validation and formatting features of these type of data.
The problem is that following the great tutorial "Continuing with EF" on this site, it seemed to be very simple using GRIDVIEW and DETAILSVIEW controls to use the DynamicControl instead it seems to be a hell using FORMVIEW. Using GridView you can simply add a class with few lines for the [MetadataType(typeof(DepartmentMetaData))] and that's all. I don't want to add too much complexity to my project just for validation and formatting.
I read also this article but I didn't find a solution.
http://csharpbits.notaclue.net/2008/10/dynamic-data-custom-pages_08.html
Maybe I need to learn more...