Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where's the row?
Message
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00749976
Message ID:
00750003
Views:
22
Duh! I knew that Cathi, I just had a brain fart! <g> I usually do that before I add the row, so it's always .Count instead of .Count - 1 at that point.

Thanks for correcting my VB syntax ... maybe I should just always post C# code so I don't confuse anyone.

~~Bonnie


>Hi Bonnie and Roland,
>
>The Position property is zero based so when the Count property is used, you need to minus one. This one has bit me in the past and then I can't figure out what went wrong. :)
>
>Here is the altered code and modified a little for VB .NET differences:
>
>
>Dim row As DataRow = ds.Tables[0].NewRow()
>ds.Tables(0).Rows.Add(row)
>BindingContext(ds, "Listing").Position = ds.Tables[0].Rows.Count - 1
>
>
>>Roland,
>>
>>I think it's been mentioned here before that it's better to add a row with the Table's NewRow() method than with the BindingContext's AddNew() method. So, you'd do something like this (remember, I use C#, so my VB syntax may be slightly off):
>>
>>
>>  DataRow row = ds.Tables[0].NewRow()
>>  ds.Tables[0].Rows.Add(row)
>>  BindingContext(ds, "Listing").Position = ds.Tables[0].Rows.Count
>>
>>
>>~~Bonnie
>>
>>
>>>Hi,
>>>
>>>When the following code is executed I get an error message:
>>>
>>>There is no row at position.
>>>
>>> 'Add a New Record
>>> Me.Pending01_DS1.Listing.Clear()
>>> Me.BindingContext(Pending01_DS1, "Listing").AddNew()
>>>
>>> ' Defaults for New Listing in Table
>>> Dim iAddCurrRow As Integer
>>> iAddCurrRow = Me.BindingContext.Pending01_DS1, "Listing").Position
>>> Me.Pending01_DS1.Tables("Listing").Rows(iAddCurrRow).Item("DateInsert") = Now
>>>
>>>Where is the row I just added with AddNew command?
>>>
>>>What do I need to do to correct this error?
>>>
>>>Thanks
>>>Roland
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform