I have moved a little ahead now I have bound the grid view with entity framework instead of code behind (so I have removed Page load event). Now my aspx page looks like
I have tried using SetMetaTable method without using INamingContainer but I didn't find the method. But once I have inherited the class I can use the method. In the sample project I am using asp.net grid view.
Participant
1731 Points
1146 Posts
Adding dynamic data behavior to gridviewewo
Mar 23, 2014 07:27 AM|karang|LINK
Hi All
I want to add dynamic data behavior in grid view. For that I have followed these steps
1. Create an entity framework.
2. Bind grid view with entity framework using following code
Then added the code on page_init event
In aspx page I have added following code
But I could see the records but I could not see the dynamic behavior. Am I missing anything?
Karan Gupta
http://gyansangrah.com
Please click "Mark as Answer" if this helped you.
Participant
1731 Points
1146 Posts
Re: Adding dynamic data behavior to gridviewewo
Mar 23, 2014 01:14 PM|karang|LINK
Hi
I have moved a little ahead now I have bound the grid view with entity framework instead of code behind (so I have removed Page load event). Now my aspx page looks like
But now I am getting following error - "Specified method is not supported." and here is the stack trace
[NotSupportedException: Specified method is not supported.]
System.Web.DynamicData.ModelProviders.SimpleDataModelProvider.CreateContext() +29
System.Web.DynamicData.MetaTable.CreateContext() +16
System.Web.DynamicData.MetaTable.System.Web.DynamicData.IMetaTable.CreateContext() +10
System.Web.DynamicData.<>c__DisplayClass4.<RegisterControlInternal>b__1(Object sender, EntityDataSourceContextCreatingEventArgs e) +14
System.Web.UI.WebControls.EntityDataSourceView.OnContextCreating(EntityDataSourceContextCreatingEventArgs e) +112
System.Web.UI.WebControls.EntityDataSourceView.ConstructContext() +62
System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +76
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +66
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
System.Web.UI.Control.EnsureChildControls() +102
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
I have searched but didn't find anything. Please help me on this.
Karan Gupta
http://gyansangrah.com
Please click "Mark as Answer" if this helped you.
All-Star
17916 Points
5681 Posts
MVP
Re: Adding dynamic data behavior to gridviewewo
Mar 23, 2014 03:12 PM|sjnaughton|LINK
I think you are missing the set metatable.
gvTest.SetMetaTable(table);
Always seeking an elegant solution.
Participant
1731 Points
1146 Posts
Re: Adding dynamic data behavior to gridviewewo
Mar 23, 2014 09:41 PM|karang|LINK
Hi
Gridview doesn't contain the definition of SetMetaTable method.
Karan Gupta
http://gyansangrah.com
Please click "Mark as Answer" if this helped you.
Participant
1731 Points
1146 Posts
Re: Adding dynamic data behavior to gridviewewo
Mar 24, 2014 01:57 PM|karang|LINK
Hi
One more step :). I have inherited the class with INamingContainer and found the method SetMetaData(). So I have changed the code to the following
But still I am getting the same error.
Karan Gupta
http://gyansangrah.com
Please click "Mark as Answer" if this helped you.
All-Star
17916 Points
5681 Posts
MVP
Re: Adding dynamic data behavior to gridviewewo
Mar 24, 2014 06:42 PM|sjnaughton|LINK
the ASP.Net GridView already implements INamingContainer, is you grid the asp.net Gridview if not I woudl not expect it to work.
Always seeking an elegant solution.
Participant
1731 Points
1146 Posts
Re: Adding dynamic data behavior to gridviewewo
Mar 24, 2014 09:44 PM|karang|LINK
Hi
I have tried using SetMetaTable method without using INamingContainer but I didn't find the method. But once I have inherited the class I can use the method. In the sample project I am using asp.net grid view.
Karan Gupta
http://gyansangrah.com
Please click "Mark as Answer" if this helped you.
All-Star
17916 Points
5681 Posts
MVP
Re: Adding dynamic data behavior to gridviewewo
Mar 25, 2014 09:42 AM|sjnaughton|LINK
try watching this Create rich, data-driven Web apps with ASP.NET 4.5 Web Forms from Build 2011 where i think Damien Edward demonstrates Model Binding with GridView.
Always seeking an elegant solution.