h1

Default values for FormView control in Insert mode

November 19, 2008

In many times we must assign default values to FormView in the insert mode. Problem is, that FW creates empty entity and this means empty FW.

Here is very short and powerful solution ;)

  • Add binding source to control which we want to set

    <asp:TextBox ID=”RateTextBox” runat=”server” Text=’<%# Bind(“Rate”) %> TabIndex=”24″ MaxLength=”5″ OnDataBinding=”InsertRateOnDataBinding />

  • Setting value to this control

    protected void InsertRateOnDataBinding(object sender, EventArgs e)
    {
      ((TextBox) sender).Text = RevertedOccupiedPercentage.ToString();
    }

Leave a Comment