Last post Apr 12, 2012 09:13 AM by sjnaughton
Apr 10, 2012 06:01 PM|tsoft|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 06:33 PM|tsoft|LINK
Can I get the EntityObject somehow in the Page_Init or Page_Load events?
Apr 10, 2012 06:43 PM|tsoft|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 11, 2012 09:27 PM|TimoYang|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 11, 2012 10:11 PM|tsoft|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 11, 2012 10:12 PM|TimoYang|LINK
Plz re-databind to the DataSource of the FormView again when rendering the page or in the Page_Load event do that……
Apr 11, 2012 10:15 PM|tsoft|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 03:01 AM|TimoYang|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 09:13 AM|sjnaughton|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.