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
 

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

bound label 4
displaying session value in formview? 1
iTemplate Formview Problem 3
what does databind do 3
formview and checkboxes 2
SqlDataSource identity 1
FormView disappears 2
force insert to show 1

Back
Top