default values from the database formview insert mode

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
 
M

Michael Nemtsev [MVP]

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?
 
A

Alexander Myachin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

FormView insert with UpdatePanel 0
FormView after insert 0
FormView Insert 6
get new formview row 0
FormView 0
Formview template insert to edit mode 1
Formview Null Values 2
FormView 3

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top