default values from the database formview insert mode

  • Thread starter Thread starter rodchar
  • Start date Start date
R

rodchar

hey all,
has anyone ever bound data to a formview that's in Insert Mode? For example,
if you had to get default values from the database for a new record?

thanks,
rodchar
 
Hello rodchar,

You need either to make a call to SQL in before add row event, to extract
default values from system tables and fill editable row
or make an silent insert of dummy values and get resulted data

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


r> hey all,
r> has anyone ever bound data to a formview that's in Insert Mode? For
r> example,
r> if you had to get default values from the database for a new record?
 
Hello rodchar,

You can try the following:

Atach an event handler to DataBinding event on the control(s) from
InsertTemplate.
<asp:TextBox id= "txtNumber" OnDataBinding =
"txtNumber_InsertDataBinding" ..

In the event handler initialize the text property.

protected void txtNumber_InsertDataBinding(object sender, EventArgs e)
{
TextBox txtNumber = (TextBox) sender;

// Retrieve and assign default number
txtNumber.Text = NewNumber();
}

Hope this helps,
Alexander Myachin
 
Back
Top