Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Editing a row in a table on p.506


Message #1 by "Kim Holman" <onemorecybergeek@y...> on Thu, 2 Jan 2003 02:23:58
Hi,

I've been working on the example for adding, deleting, and editing table 
rows. It's located on pages 504 through 507 in the book. In part 5 of the 
example on page 506, there seems to be an error. Since I couldn't find 
any typos, I actually went to the downloaded source code and copied this 
section into my page (the rest of the page works fine except for this one 
area). This is the code:

//Marker 2
  //Find the row to change
    DataRow[] objRows = objTable.Select("FirstName='Margaret' AND 
LastName='Peacock'");
    objRows[0]["FirstName"] = "John";
    objRows[0]["LastName"] = "Hartford";

    // Bind the data grid to the new data
    dgNameList3.DataSource = objTable.DefaultView;
    dgNameList3.DataBind();

And this is the error message I get:

Index was outside the bounds of the array. 
Description: An unhandled exception occurred during the execution of the 
current web request. Please review the stack trace for more information 
about the error and where it originated in the code. 

Exception Details: System.IndexOutOfRangeException: Index was outside the 
bounds of the array.

Source Error (highlighted for Line 40): 


Line 38:   // Find the row to change
Line 39:     DataRow[] objRows = objTable.Select("FirstName='Margaret' 
AND LastName='Peacock'");
Line 40:     objRows[4]["FirstName"] = "John";
Line 41:     objRows[4]["LastName"] = "Hartford";
Line 42: 
 
Can anyone tell me how to fix this? I didn't find any errata listed for 
chapter 13 on the site.

Thanks in advance for any help.

Kim Holman
Message #2 by philp@w... on Thu, 2 Jan 2003 10:14:46
> Hi,

> I've been working on the example for adding, deleting, and editing table 
r> ows. It's located on pages 504 through 507 in the book. In part 5 of 
the 
e> xample on page 506, there seems to be an error. Since I couldn't find 
a> ny typos, I actually went to the downloaded source code and copied this 
s> ection into my page (the rest of the page works fine except for this 
one 
a> rea). This is the code:

> //Marker 2
 >  //Find the row to change
 >    DataRow[] objRows = objTable.Select("FirstName='Margaret' AND 
L> astName='Peacock'");
 >    objRows[0]["FirstName"] = "John";
 >    objRows[0]["LastName"] = "Hartford";

>     // Bind the data grid to the new data
 >    dgNameList3.DataSource = objTable.DefaultView;
 >    dgNameList3.DataBind();

> And this is the error message I get:

> Index was outside the bounds of the array. 
D> escription: An unhandled exception occurred during the execution of the 
c> urrent web request. Please review the stack trace for more information 
a> bout the error and where it originated in the code. 

> Exception Details: System.IndexOutOfRangeException: Index was outside 
the 
b> ounds of the array.

> Source Error (highlighted for Line 40): 

> 
L> ine 38:   // Find the row to change
L> ine 39:     DataRow[] objRows = objTable.Select("FirstName='Margaret' 
A> ND LastName='Peacock'");
L> ine 40:     objRows[4]["FirstName"] = "John";
L> ine 41:     objRows[4]["LastName"] = "Hartford";
L> ine 42: 
 > 
C> an anyone tell me how to fix this? I didn't find any errata listed for 
c> hapter 13 on the site.

> Thanks in advance for any help.

> Kim Holman


Please note the information regarding book specific support questions in 
the P2P FAQ.  I would like to explain the Wrox support process. If you 
wish to directly query a problem in the book with an expert who knows the 
book in detail then e-mail support@w... , with the title of the book 
and the last four numbers of the ISBN in the subject field of the e-mail.  
Please also confirm the software that you are using (include versions / 
editions / service packs etc.).  Please specify whether you are receiving 
any error messages (or a description of what is happening on your screen 
as opposed to what is being described in the book)

Phil Perks
Technical Support Manager
Wrox Press
Message #3 by "Kim Holman" <onemorecybergeek@y...> on Tue, 7 Jan 2003 04:12:52
Hi Phil,

I appreciate your guidance in explaining the support process to me. 
However, I have not received a reply to my email, except to say it was 
being passed along. So I'm still wondering if anyone out there can see 
the mistake in this code example.

Thanks,
Kim


Please note the information regarding book specific support questions in 
the P2P FAQ.  I would like to explain the Wrox support process. If you 
wish to directly query a problem in the book with an expert who knows the 
book in detail then e-mail support@w... , with the title of the book 
and the last four numbers of the ISBN in the subject field of the e-mail.
  
Please also confirm the software that you are using (include versions / 
editions / service packs etc.).  Please specify whether you are receiving 
any error messages (or a description of what is happening on your screen 
as opposed to what is being described in the book)

Phil Perks
Technical Support Manager
Wrox Press

  Return to Index