Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 12, 2012 01:13 PM by sjnaughton
Apr 10, 2012 10:01 PM|LINK
Hopefully this is a simple question. Here's what I am trying to do:
1. Add table/entityobject specific buttons to the Edit.aspx page in the Dynamic Data framework. (I will do this by reflecting the type and creating buttons for all methods marked "DynamicDataWebMethod")
2. Add these buttons during Page_Init so the OnClick event triggers.
3. In my OnClick event, How can I get the FormView DataItem? The DataItem that inherits from EntityObject? When I get into the OnClick method the FormView1 has not been bound yet. How can I force it to be bound? Is there another way to get the EntityObject?
I just need help with #3. :)
Thanks in advance!
Apr 10, 2012 10:33 PM|LINK
Can I get the EntityObject somehow in the Page_Init or Page_Load events?
Apr 10, 2012 10:43 PM|LINK
Just for fun here is a mock up of my data class:
partial class IT_Servers : IAuditable
public class Metadata
public object Id;
public object ServerName;
public void TurnOffPower()
Apr 12, 2012 01:27 AM|LINK
How can I get the FormView DataItem?
Please handle the FormView_ItemDataBound and you can get the DataItem through the parameter of "e"，which is auto-generated……
Apr 12, 2012 02:11 AM|LINK
Timo, Thank you for the idea but I don't think it will work due to the way the page life-cycle works.
The problem is that I am trying to access the DataItem from the OnClick event of a LinkButton. When this event is being triggered the FormView.DataItem is null.
Isn't there a way to get the EntityObject in the Page_Init or Page_Load events?
Apr 12, 2012 02:12 AM|LINK
Plz re-databind to the DataSource of the FormView again when rendering the page or in the Page_Load event do that……
Apr 12, 2012 02:15 AM|LINK
I have tried to call FormView.DataBind() from the Page_Load event as you suggested and it fails. How do you trigger it?
If I call DataBind() in OnClick it does indeed bind and I can work with the DataItem object.. This a step in the right direction but I need to access it earlier.
Is there a way to get the EntityObject from the MetaTable "table" object? I tried reflecting it and could not find the DataItem (though I could find the Type.. but I'd like access to the column values so I can make design decisions).
Apr 12, 2012 07:01 AM|LINK
I have tried to call FormView.DataBind() from the Page_Load event as you suggested and it fails.
Why？Show us your codes……
Apr 12, 2012 01:13 PM|LINK
Hi Tsoft, what is it you are trying to achive, with DD it's somtimes better to descibe what it is you want o achive, as there are often simpler or beter way to do things in DD.