Gridview update problems

M

marti

I've run into three problems trying to solve this one issue.
Using VS2005 B2 & sql server 2000, I create a sqldatasource and bind a
gridview to it. Everything looks good. However, if there is an original
value of Null in a field, the auto-generated update to the table fails
because the sql statement says "where field1 = Null" instead of "where
field1 is Null". I've pasted versions of the sql statement from
profiler to query analyzer and they all are the same, "is null" works,
"= null" fails.
So I try to change the sql statement that's sent in the
GridView_RowUpdating event using e.OldValues(FieldName). This seems to
always evaluate to Nothing, eventhough there are an appropiate count of
FieldName's within e.OldValues.Keys.
So I try to change the sql statement using SqlDatasource_Updating
event using e.Command.Parameters(i).Value , which gives a
NullReferenceException, eventhough the
e.Command.Parameters(i).ParameterName shows the correct field name.
I've tried everything I can think of, can you give me some ideas
as to some possible causes for these? Thanks for any clues!
-Jeff
 
S

S. Justin Gengo

Jeff,

The final version of Visual Studio.NET 2005 has now been released. I would
switch to that first just to see if the problem's been solved there.


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
G

Guest

THis is *NOT* fixed in the RTM. Makes concurrency and the SqlDataSource
completely unusable. Please don't tell us to disallow null's in our tables
to make this work.

Shawn Wildermuth (MVP)
 
S

S. Justin Gengo

Shawn,

Darn, I was hoping that it might have been fixed. No, I wouldn't disallow
nulls. But I'm not positive what the fix is. I haven't worked with Visual
Studio.Net 2005 enough yet to have run into the same problem. You may need
to put a check into the databind routine to get this to work.

Does anyone else know how to solve this problem?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
G

Guest

I have been manually changing the sql generated by the wizard to do the right
thing. In my case I am using rowversions in the database to do concurrency.
I hope to have a write up on it for my website in the next day or so.
 

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


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top