PDA

View Full Version : Error when want to Edit the datagrid


vinosha83
09-27-2007, 07:20 AM
hi anybody help me ....i no idea why got errror when i edit my datagrid column..
please help me..
i got errro in below code

Function GetMaterialSelectedIndex(ByVal Value As Object) As Integer
Dim t As Integer


Dim dt As DataTable = dsUser.Tables("Material")
For t = 0 To dt.Rows.Count - 1
If dt.Rows(t)("MaterialType") = Value Then

Return t
End If
Next

End Function

the error page

Server Error in '/EIASystem' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 87:
Line 88: Dim dt As DataTable = dsUser.Tables("Material")
Line 89: [b] For t = 0 To dt.Rows.Count - 1 Line 90: If dt.Rows(t)("MaterialType") = Value Then
Line 91:

jleone
09-27-2007, 02:47 PM
Where is "dsUser" declared and how does it receive it's value? Is "dsUser" your datagrid itself? Please post some additional code from your code behind page to see what's going on.

If "dsUser" doesn't contain a value then "dt" = Nothing, thus "dt" would be the object not set to an instance of an object when you reference it in your "For" loop.

vinosha83
09-28-2007, 02:25 AM
hi...........able to solve the problem ..........thnaks..............