Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Formview, missing data on newvalues, oldvalues, keys

 
Thread Tools Search this Thread
Old 05-28-2009, 10:40 PM   #1
Default Formview, missing data on newvalues, oldvalues, keys


Hello.

I have a formview object that shows a record and lets users update
fields, and they then press the "update" button, and I want it to update. It
looks like pretty standard stuff, but it doesn't update.

Here's my formview declaration, followed by the usual string of text boxes,
labels, etc. all bound to fields. They work.

<asp:FormView ID="FormView1" runat="server" DataKeyNames="RFQID"
DataSourceID="SqlDataSourceRFQ"
onitemcommand="FormView1_ItemCommand"
onitemupdating="FormView1_ItemUpdating"
onmodechanged="FormView1_ModeChanged" Width="100%">

None of the methods do anything special. They just set a couple of
variables. That will be used in later processing, except it never gets to the
later processing. It ends up throwing an exception during the Update.

The fields are all displayed correctly, with the correct data.

The Update button is just the default linkbutton

<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True"
CommandName="Update" Text="Update" />

I notice when I set a breakpoint in the onitemupdate function, I can examing
newvalues, oldvalues, and keys. None of them have any data. They are all
zero length collections.

What happened to the data? What would prevent the data from being sent to
the onitemupdate event handler?




David
  Reply With Quote
Old 05-29-2009, 03:07 AM   #2
Allen Chen [MSFT]
 
Posts: n/a
Default RE: Formview, missing data on newvalues, oldvalues, keys
Hi David,

>None of the methods do anything special. They just set a couple of
>variables. That will be used in later processing, except it never gets to

the
>later processing. It ends up throwing an exception during the Update.


Could you tell me the exception message first?

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.





Allen Chen [MSFT]
  Reply With Quote
Old 05-29-2009, 04:32 PM   #3
David
 
Posts: n/a
Default RE: Formview, missing data on newvalues, oldvalues, keys
Yes. I get a Null value message on the update. All of the parameters in the
Update statement end up being set to null, so when the sqldatasource object
goes to execute the update, it fails on a field that does not allow nulls.

(Hmmm....Maybe I'll put in a required field validator on one of them, and
make sure it is passing. I suspect it will, but I haven't tried it yet.)

"Allen Chen [MSFT]" wrote:

> Hi David,
>
> >None of the methods do anything special. They just set a couple of
> >variables. That will be used in later processing, except it never gets to

> the
> >later processing. It ends up throwing an exception during the Update.

>
> Could you tell me the exception message first?
>
> Regards,
> Allen Chen
> Microsoft Online Support
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> .
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/en-us/subs...#notifications.
>
> Note: MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 2 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions. Issues of this
> nature are best handled working with a dedicated Microsoft Support Engineer
> by contacting Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>



David
  Reply With Quote
Old 06-01-2009, 02:45 AM   #4
Allen Chen [MSFT]
 
Posts: n/a
Default RE: Formview, missing data on newvalues, oldvalues, keys
Hi David,

>Yes. I get a Null value message on the update. All of the parameters in

the
>Update statement end up being set to null, so when the sqldatasource

object
>goes to execute the update, it fails on a field that does not allow nulls.


>(Hmmm....Maybe I'll put in a required field validator on one of them, and
>make sure it is passing. I suspect it will, but I haven't tried it yet.)



Thanks for your reply. From your description the parameters are somehow
lost before updating, right? Could you send me a demo that can reproduce
this issue? My email is se update here after
sending the project in case I missed that email.

Regards,
Allen Chen
Microsoft Online Support



Allen Chen [MSFT]
  Reply With Quote
Old 06-01-2009, 04:11 PM   #5
David
 
Posts: n/a
Default RE: Formview, missing data on newvalues, oldvalues, keys
I tried to strip out as much as I could, and in the course of the action, I
found the offending statements. It seems that the problem is somehow related
to enclosing the fields of the edit template inside a table. I, of course,
had no clue about this, and still don't know what the deal is.

At any rate, this one doesn't work:


<EditItemTemplate>
<asp:Table ID="tblRFQ" runat="server" Width="100%">
<asp:TableRow>
<asp:TableCell ID="tbcRFQ" runat="server" Width="30%">RFQID:
<asp:Label ID="RFQIDLabel1" runat="server" Text='<%#
Bind("RFQID") %>' />

</asp:TableCell><asp:TableCell ID="tbcTitle" runat="server"
Width="40%"><asp:Label ID="lblFormTitle" runat="server" Text="Sales
Initiation Form" Font-Size="Large"
Width="30%"></asp:Label></asp:TableCell><asp:TableCell ID="tbcQuoteDate"
runat="server" Width="30%"></asp:TableCell></asp:TableRow><asp:TableRow
Width="100%">
<asp:TableCell Width="50%" HorizontalAlign="Left" >Requestor:
<asp:TextBox ID="tbRequestor" runat="server" Text='<%# Bind("Requestor") %>'
></asp:TextBox>

<asp:RequiredFieldValidator ID="requestorrequired" runat="server"
ControlToValidate="tbRequestor" Text="Required"></asp:RequiredFieldValidator>
</asp:TableCell></asp:TableRow></asp:Table><br />

<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel"/>
</EditItemTemplate>



This one works fine:

<EditItemTemplate>


RFQID:
<asp:Label ID="RFQIDLabel1" runat="server" Text='<%#
Bind("RFQID") %>' />

<asp:Label ID="lblFormTitle" runat="server" Text="Sales Initiation
Form" Font-Size="Large" Width="30%"></asp:Label>
Requestor: <asp:TextBox ID="tbRequestor" runat="server" Text='<%#
Bind("Requestor") %>' ></asp:TextBox>
<asp:RequiredFieldValidator ID="requestorrequired" runat="server"
ControlToValidate="tbRequestor" Text="Required"></asp:RequiredFieldValidator>
<br />

<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel"/>
</EditItemTemplate>


The only difference is that the table, and its tablerow and tablecell
objects, have been removed from the markup. The first indication I get of a
problem is in the ItemUpdating event handler. When the fields are enclosed
in a table, the "OldValues" field has a 0 length array. When there is no
table, it is an array of length 1 (the requestor.) The required field
validator works fine for both cases.


So, as I'm sure happens often, the thing that was causing the problem is
something I omitted from my original description. My modified question is
what do so that the values bound to data inside the table is updated and
passed on to the Update event of the ItemUpdating field of my formview, and
then to my Updating even of the SQLDataSource.




"Allen Chen [MSFT]" wrote:

> Hi David,
>
> >Yes. I get a Null value message on the update. All of the parameters in

> the
> >Update statement end up being set to null, so when the sqldatasource

> object
> >goes to execute the update, it fails on a field that does not allow nulls.

>
> >(Hmmm....Maybe I'll put in a required field validator on one of them, and
> >make sure it is passing. I suspect it will, but I haven't tried it yet.)

>
>
> Thanks for your reply. From your description the parameters are somehow
> lost before updating, right? Could you send me a demo that can reproduce
> this issue? My email is se update here after
> sending the project in case I missed that email.
>
> Regards,
> Allen Chen
> Microsoft Online Support
>
>



David
  Reply With Quote
Old 06-01-2009, 06:38 PM   #6
David
 
Posts: n/a
Default RE: Formview, missing data on newvalues, oldvalues, keys
Now that I know the problem, a quick google found that these two items don't
work together.

http://msdn.microsoft.com/en-us/libr...pdating.as px

Apparently, you can't put an ASP:Table object inside an edititem template.

Thanks for the help in locating this issue.
"Allen Chen [MSFT]" wrote:

> Hi David,
>
> >Yes. I get a Null value message on the update. All of the parameters in

> the
> >Update statement end up being set to null, so when the sqldatasource

> object
> >goes to execute the update, it fails on a field that does not allow nulls.

>
> >(Hmmm....Maybe I'll put in a required field validator on one of them, and
> >make sure it is passing. I suspect it will, but I haven't tried it yet.)

>
>
> Thanks for your reply. From your description the parameters are somehow
> lost before updating, right? Could you send me a demo that can reproduce
> this issue? My email is se update here after
> sending the project in case I missed that email.
>
> Regards,
> Allen Chen
> Microsoft Online Support
>
>



David
  Reply With Quote
Old 11-03-2009, 12:27 PM   #7
nasa
Junior Member
 
Join Date: Nov 2009
Posts: 1
Default Formview Updatecommand is passing Nulls to SQL Query
I have created an EditItemTemplate in my Formview. The ItemTemplate displays the information correctly, Pressing Edit brings up the EditItemTemplate nicely. When I edit some fields and press Update it sends a query off to the SQL server but it my SQL trace reveals that sends it with a NULL in every the parameters. Since I have correctly identified the DataKeyNames value it finds the right record and overrights all the values with nulls. And also i dont have any ASP:Table object in my EditItemTemplate. I am stuck here big time. Need your urgent help.


nasa
nasa is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Formview with ObjectDataSource rturner003 Software 0 10-26-2006 12:26 PM
Missing NTLDR, etc on Win XP Pro,Tried everything, HELP! James A+ Certification 0 01-12-2005 02:12 AM
New Releases: Terminal, Missing & Forbin Project: Updated complete downloadable R1 DVD DB & info lists Doug MacLean DVD Video 1 09-22-2004 12:57 AM
Why is there Footage Missing from the Matrix DVD? Paul DVD Video 2 02-15-2004 04:07 AM
DVD rip is shorter than the original and the Divx encode is evenshorter with missing microchunks - help? gaffo DVD Video 10 09-25-2003 02:31 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46