473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Formview and objectdatasource with int values and null textboxes

Pao
I use a formview control bounded to an objectdatasource to insert a
record.
So when I have some textboxes with no values, and the property of my
object is Int, it generates client side an error.
I tried to intercept some event like OnInserting, but the error gets
before.
How can I generate the textboxes in the insert template by putting a
"0" on integer fields, if I have
the Bind clause?
example:
Expand|Select|Wrap|Line Numbers
  1. <td width="33%"><b>NumCiv: </b><asp:TextBox ID="txtNumCiv"
  2. runat="server"
  3. Text='<%# Bind("NumCiv") %>'
  4. Enabled="true"></asp:TextBox></td>
  5.  
If I can't, are there some other way to solve the problem?
thanks

Dec 30 '06 #1
1 2730
Pao
I answer myself

protected void FormViewPS_PreRender(object sender, EventArgs e)
{

if (((FormView)sender).CurrentMode == FormViewMode.Insert)
{
TextBox txttmp = (TextBox )FormViewPS.Row.FindControl("textboxdata ");

if (txttmp.Text=="") txttmp.Text="0";
}
}

Dec 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ottar | last post by:
I have a few numeric fields, and when I update i get the error: "Input string was not in a correct format". Next line:" System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&...
7
by: Lorenzino | last post by:
Hi, I have a problem with bindings in a formview. I have a formview; in the insert template i've created a wizard control and inside it i have an HTML table with some textboxes bound to the...
4
by: J055 | last post by:
Hi I have 2 update buttons in my FormView ('Apply' and 'OK'). I want both buttons to update the data source but the 'OK' button should redirect afterwards. I can see which button is clicked...
1
by: Q. John Chen | last post by:
I have a table T with following columns for example ID, ParentID, ApptDateTime, UpdatedBy On formView I want display the ApptDate and Time seperately with two textBoxes. In itemTemplate, I...
1
by: Pao | last post by:
I have a formview bounded to an objectdatasource. All ok but I have some trouble with a checkbox: when I am in update mode and I update the record, this field is never updated (no errors thrown)....
0
by: =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?= | last post by:
Hello, I read some msdn and other articles about how does databinding among DataSource controls and FormView / GridView controls works but I still don't fully understand to this blackbox. I have...
8
by: =?Utf-8?B?QXNo?= | last post by:
Hi, I have an object, for example User. User contains various properties which i have been able to bind to successfully using wizards and the form view. However if the class User has a property...
5
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a...
2
by: Matt MacDonald | last post by:
Hi all, I'm having an issue that's driving me crazy. I have a datatable that I need to display all the information for on a page. So, instead of manually coding every single column to a label, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.