VB.NET - error encountered please see

Asked By sarah lee
05-Oct-06 10:23 AM

hi all

can anyone please help me in resolving this error?

Compiler Error Message: BC30311: Value of type 'System.Data.DataTable' cannot be converted to 'System.Data.DataRow'.

Source Error:

Line 56:     
Line 57:     dim product as DataRow
Line 58:     product= cartoperation.GetProducts(ProductID)
Line 59:     
Line 60:     dim shoppingCart as  cartoperation.OrderList

 

thanks

Updated Code  Updated Code

05-Oct-06 10:28 AM

Since the output of your GetProducts method is a DataTable, you have to define product as a DataTable as well:

Dim product As DataTable

product = cartoperation.GetProducts(ProductID)

can you please say  can you please say

05-Oct-06 10:52 AM

Sir, can you please see this error?

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Source Error:

Line 126:    
Line 127:    dim ProductID as integer
Line 128:    ProductID = int32.parse(productListing.datakeys(ProductListing.selectedindex).toString())
Line 129:    
Line 130:    dim product as datarow

When i selected a particular category, to browse through it, the error occured, what can be the reason?

thanks for all your help

 

Updated Code  Updated Code

05-Oct-06 10:56 AM

Instead of using the SelectedIndex of the ProductListing object, try using the SelectedValue:

ProductID = int32.parse(productListing.datakeys(ProductListing.SelectedValue).toString())

it says selectedValue is not a member of datalist  it says selectedValue is not a member of datalist
05-Oct-06 11:01 AM
end of post
  Sushila Patel replied to sarah lee
05-Oct-06 11:21 AM

You might get this error if you miss out on giving the Datakeyfield for the DataList

 

i have given  i have given
05-Oct-06 12:21 PM

but i have given datakeyfield value for the 2 datalists which i am using

then why is this occuring

can you please guide me

thanks

  Sushila Patel replied to F Cali
05-Oct-06 02:22 PM

DataList.Selected value is new in .NET Framework 2.0

If you are using 1.1 and you are writing code in the Item_Command/Item_DataBound event or so

you will use e.Item.ItemIndex 

So in code with appropriate event that you trigger

it should be

ProductID = int32.parse(productListing.datakeys(e.Item.ItemIndex).toString())

 

 

Create New Account
help
ArgumentOutOfRangeException .NET Framework I am throwing the ArgumentOutOfRangeException in my code as shown below throw new ArgumentOutOfRangeException("value", "Value must be > 0"); my catch block is below catch(ArgumentOutOfRangeException exception) { MessageBox.Show(exception.Message, "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } / / end catch My question is the message box shows both my custom error of "Value must be I am requesting is the exception.Message? Thanks for your help
ArgumentOutOfRangeException .NET Framework Hello, I created a string extension to trim a string and add a ". . ." at the end if the string was trimmed. I am getting an error: Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of Remove initial empty spaces value.Trim(); / / Check inputs if (length = = 0) if (ellipsis) throw new ArgumentOutOfRangeException(); else return String.Empty; if (value.Length < length) return value; / / Trim String trimmed = value.Substring Substring(0, i); return ellipsis ? trimmed + ' \ x2026' : trimmed; } / / Trim / / - -- -- -- -- - End Code - -- -- -- -- - Thanks, Miguel C# Discussions ArgumentOutOfRangeException (1) LastIndexOfAny (1) Trimmed.LastIndexOfAny (1) String.Format (1) String.Empty (1) Substring (1) Remove value = 3D value.Trim(); / / Check inputs if (length = 3D = 3D 0) if (ellipsis) throw new ArgumentOutOfRangeException(); else return String.Empty; if (value.Length < length) return value; / / Trim String trimmed = 3D value 0, i ! = -1 ? i : cchMax); return ellipsis ? trimmed + ' \ x2026' : trimmed; Hope that helps. Pete keywords: ArgumentOutOfRangeException description: Hello, I created a string extension to trim a string and add a . . . at
Baudrate error? .NET Framework Hi, I'm using the serial port on a Pocket PC (Mobile 2003 - CF try to set the Baud rate like: MyPort.BaudRate = 115200; I get this exception: {System.ArgumentOutOfRangeException: Argument must be between 0 and 65536. Parameter name: baudRate at System.IO.Ports.SerialStream other applications) Any idea what could be wrong?? Your help is highly appreciated! Thanks, Ole .NET Compact Framework Discussions ArgumentOutOfRangeException (1) SerialStream (1) SerialPort (1) Ports (1) Ole (1) Hi, Did you check the serial the very same Pocket PC by using calls to the API. Thanks Ole keywords: Baudrate, error? description: Hi, I'm using the serial port on a Pocket PC (Mobile 2003 - CF
Converting c# to vb.net .NET Framework Hi I've run some binary tree c# code on various on-line converters. The code compiles fine in c# but raises a few issues in vb.net. This is all pretty new to me, so if this is obvious pls excuse me If index = 0 Then Return m_leftSubtree ElseIf index = 1 Then Return m_rightSubtree Else Throw New ArgumentOutOfRangeException() End If End Function Function GetChild(ByVal index As Integer) As ITree(Of T) Implements ITree(Of T).GetChild Return Me.GetChild(index) End Function Error 7 'Public Function GetChild(index As Integer) As ITree(Of T)' and 'Public Function GetChild Contains(ByVal item As T) As Boolean Using enumerator As IEnumerator(Of T) = Me.GetEnumerator() . . . Error 8 Option Strict On disallows implicit conversions from 'System.Collections.IEnumerator' to 'System.Collections.Generic.IEnumerator(Of T)'. VB.NET Discussions System.Collections.IEnumerable.GetEnumerator (1) ArgumentOutOfRangeException (1) System.Collections.IEnumerable (1) System.Collections.IEnumerator (1) Python (1) VB (1) GetEnumerator (1
Page Level error in Asp.Net Hello, I want an example of PageLevel Errors in asp.net. . . . With explaination. . . . Thanks in advance. . . From my point of view, you should do error handling both on page level appliation level. It does not look good if you show a generic error even if a user inputs simple wrong data in a field. The error message should be meaningful. For all know type of errors, you should provide page level error handling and in case if any new exception rises, then there is always the application level handling. http: / / forums.asp.net / t / 1648098.aspx / 1 Hi, Every time you create a web form in Visual Studio