I have custom control with two textboxes and one drop down list. I want to make it two-way data bound, so when I put it into ie. Details View control like this:
<asp:MyCustomControl ID="MyId" runat="server" Value1='<%# Bind("val1") %>'>
</asp:MyCustomControl>
then it should work like regular TextBox..
In my control I have Value1 defined:
[
Bindable(true, BindingDirection.TwoWay),
Browsable(true),
DefaultValue(0),
PersistenceMode(PersistenceMode.Attribute)
]
public double Value1
{
get
{
if(ViewState["Value1"]==null)
return 0;
return (double)ViewState["Value1"];
}
set
{
ViewState["Value1"] = value;
}
}
I want this control to keep simple.
What am I missing?
I’ve found some kind of workaround. The property in control (ascx.cs) now looks like this:
And that works as I need.