![]() |
|
|
|||||||
![]() |
ASP Net - Formview, missing data on newvalues, oldvalues, keys |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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] |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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] |
|
|
|
#5 |
|
Posts: n/a
|
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 |
|
|
|
#6 |
|
Posts: n/a
|
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 |
|
|
|
#7 |
|
Junior Member
Join Date: Nov 2009
Posts: 1
|
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 |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |