FormViews - ASP.NET 2.0

J

Just Me

OK, im really struggling with something which sould really be simple I
think.

Ive created an SQL Datasource on a web form and dragged a formview, editted
the Insert Template to make it look nice in a table etc. The table itself
has lots of fields ( About 20 ) and I have set up an Insert statement in the
SQLDatasource, and tested in that that I can insert a record.

So far so good.


Now where I am missing knowledge is how to make the data held in the
formview get updated.

So, my Insert statrement looks something like.

Insert Into Users( NickName) Values(@Nickname) // Obviously there are
more fields

Nows I can execute this in the datasource config an successfully create the
records. However, Im at a bit of a loss as to how to do this fromt he form.

The Isnert Template has bound fields to all the table records.

In the Insert Click handler, I do

Me.formview1.insert(false)

This tried to do the Insert, but I get an exception to tell me that the
value of the nickname field is Null.. What Do I need to do to set up the
connection between the Insert Template and the parameters in the Insert
query

Many Thanks
 
C

Cowboy \(Gregory A. Beamer\)

The way I normally do it.

1. Test the fields in the form
2. If there are any nulls, cast them, in the DataSet, to their proper SQL
Type

value = SqlString.Null

as an example.

As long as the field can legally accept null values, this should solve your
issue. A bit heavier than drag and drop, but explicit code is bettter. :)
 
E

Evan M.

OK, im really struggling with something which sould really be simple I
think.

Ive created an SQL Datasource on a web form and dragged a formview, editted
the Insert Template to make it look nice in a table etc. The table itself
has lots of fields ( About 20 ) and I have set up an Insert statement in the
SQLDatasource, and tested in that that I can insert a record.

So far so good.

Now where I am missing knowledge is how to make the data held in the
formview get updated.

So, my Insert statrement looks something like.

Insert Into Users( NickName) Values(@Nickname) // Obviously there are
more fields

Nows I can execute this in the datasource config an successfully create the
records. However, Im at a bit of a loss as to how to do this fromt he form.

The Isnert Template has bound fields to all the table records.

In the Insert Click handler, I do

Me.formview1.insert(false)

This tried to do the Insert, but I get an exception to tell me that the
value of the nickname field is Null.. What Do I need to do to set up the
connection between the Insert Template and the parameters in the Insert
query

Many Thanks

Can we get some sample code of what you're doing? My first guess would
be that the names of your parameters in your insert statement aren't
matching up with the names of your parameters and your Bind calls in
your InsertItemTemplate
 

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

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,145
Latest member
web3PRAgeency
Top