Wrox Programmer Forums
|
BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003
This is the forum to discuss the Wrox book Professional VB.NET 2003 by Bill Evjen, Billy Hollis, Rockford Lhotka, Tim McCarthy, Jonathan Pinnock, Rama Ramachandran, Bill Sheldon; ISBN: 9780764559921
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2003, 03:38 AM
Authorized User
 
Join Date: Jun 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataGrids Update Project not working

Hi:

I'm having trouble with the DataGrids Update Project. It all seems fine, except the update never happens. I've tried to troubleshoot it, and I think I see where the problem is, but I have no idea how to fix it.

After editing the title field and clicking on the 'Update Now' link and placing a breakpoint on

objTextBox = E.Item.FindControl("edit_title")
objCommand.Parameters("@Title").Value = objTextBox.Text

I used the immediate window to show the value of objTextBox.Text, and it still refers to the unmodified value. Obviously, that's a problem, but I don't know what to do about it. If I use the immediate window to modify the objTextBox.Text value for '@Title' and then continue to run, the update works just fine.

If it helps, here is the source from my page while in edit mode:


<tr style="background-color:WhiteSmoke;">

<td nowrap="nowrap">
<a href="javascript:__doPostBack('grdAuthors:_ctl5:_c tl0','')">Update Row</a>&nbsp;<a href="javascript:__doPostBack('grdAuthors:_ctl5:_c tl1','')">Cancel Edit</a>
</td>

<td nowrap="nowrap">
DeFrance
</td>

<td nowrap="nowrap">
Michel
</td>

<td nowrap="nowrap">
<input name="grdAuthors:_ctl5:edit_title" type="text" value="The Gourmet Microwave" id="grdAuthors__ctl5_edit_title" style="font-family:Verdana;font-size:8pt;width:400px;" />
</td>

<td align="Right">
<input name="grdAuthors:_ctl5:edit_price" type="text" value="$2.99" id="grdAuthors__ctl5_edit_price" style="font-family:Verdana;font-size:8pt;width:50px;" />
</td>

</tr>

The only other potential gotcha that I can think of is that I'm currently using VB.Net 2002, not 2003. Waiting for my 2003 update. I'd be surprised if that is the difference, but not overly so. I looked for a specific VB.NET 2003 requirement, but I didn't find any.

I downloaded the code for the book, but this project isn't included, only the Client-Server Processing project.

Thanks for any help that you can provide.

JK
 
Old July 7th, 2003, 03:00 PM
Authorized User
 
Join Date: Jun 2003
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JonathanC
Default

Hi John

Sounds as if the datagrid is being updated before you read the values.
When you bind the datasource (load event) - make sure that there is code like

if not (IsPostBack) then
 'bind your grid
end if

you can send me your source and I'll have a look for you if you'd like?



Jonathan Crossland
http://www.jonathancrossland.com
 
Old July 7th, 2003, 04:29 PM
Authorized User
 
Join Date: Jun 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Jonathan:

You pointed me at the right place and I found the problem. I originally had problems making it work and I tried a number of things to make it work. I must have eventually found the real problem (code not where it was supposed to be, I'm sure), but one of my earlier attempts masked that success.

Bottom line:

In an attempt to get something to happen, I modified the Load event with:

If Not(IsPostBack)
     BindGrid()
Else
     BindGrid()
End If

which, as you surmised, binds the original data to the datagrid and never sees the modified value. However, the editing text box wasn't updated to show the original data, but instead continued to show the modified data, so I didn't see anything to indicate an underlying value change took place.

Sorry for the error. Thanks for the help.

By the way, the update mechanism used is an interesting technique. I need to think about it some more. The book is very helpful. Thanks again.

JK






Similar Threads
Thread Thread Starter Forum Replies Last Post
Project doesn't update products/ Rachel ASP.NET 3.5 Basics 2 December 7th, 2008 02:15 PM
TheBeerhouse Project working correctly in VS 2008 asp125 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 October 10th, 2008 12:33 PM
How to insert,delete,update datagrids to MS Access maximus101 VB Databases Basics 0 May 8th, 2006 03:03 PM
FileShare Project Not Working shawn BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 April 26th, 2006 01:18 PM
problems working two person on same project debuajm General .NET 5 June 11th, 2004 01:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.