A
adiel_g
I have the following function working correctly in VB.NET which
updates a table ON THE FLY in viewstate. (without copying it to a
datatable object and then back to viewstate again after editing it):
Public Function updateUser(ByVal userId As String, _
ByVal firstName As String, _
ByVal lastName As String) As
Boolean
Dim rowIndex As Integer
' Find the index of the record to update
rowIndex = ViewState("dtTempUserTable").Rows.IndexOf
(ViewState("dtTempUserTable").Rows.Find(userId))
' Update record
ViewState("dtTempUserTable").Rows(rowIndex).Item
("firstName") = firstName
ViewState("dtTempUserTable").Rows(rowIndex).Item
("lastName") = lastName
' Normal Completion
Return True
End Function
I need to use the same function in C# so I created the following code:
public bool updateUser(string userId, string firstName, string
lastName)
{
int rowIndex = 0;
// Find the index of the record to update
rowIndex = ViewState["dtTempUserTable"].Rows.IndexOf
(ViewState["dtTempUserTable"].Rows.Find(userId));
// Update record
ViewState["dtTempUserTable"].Rows[rowIndex].Item
["firstName"] = firstName;
ViewState["dtTempUserTable"].Rows[rowIndex].Item
["lastName"] = lastName;
// Normal Completion
return true;
}
Now I am receiving the following error reguarding viewstate not
finding the Rows method:
'Object' does not contain a definition for 'rows' and no extension
method 'Rows' accepting a first argument of type 'object' could be
found.
I would like to be able to perform the exact same operation I am doing
in VB.NET in C#. (Without having to move the object to a temporary
datatable object and then back again into viewstate) What am I
missing?
Thanks Before Hand,
Adiel
updates a table ON THE FLY in viewstate. (without copying it to a
datatable object and then back to viewstate again after editing it):
Public Function updateUser(ByVal userId As String, _
ByVal firstName As String, _
ByVal lastName As String) As
Boolean
Dim rowIndex As Integer
' Find the index of the record to update
rowIndex = ViewState("dtTempUserTable").Rows.IndexOf
(ViewState("dtTempUserTable").Rows.Find(userId))
' Update record
ViewState("dtTempUserTable").Rows(rowIndex).Item
("firstName") = firstName
ViewState("dtTempUserTable").Rows(rowIndex).Item
("lastName") = lastName
' Normal Completion
Return True
End Function
I need to use the same function in C# so I created the following code:
public bool updateUser(string userId, string firstName, string
lastName)
{
int rowIndex = 0;
// Find the index of the record to update
rowIndex = ViewState["dtTempUserTable"].Rows.IndexOf
(ViewState["dtTempUserTable"].Rows.Find(userId));
// Update record
ViewState["dtTempUserTable"].Rows[rowIndex].Item
["firstName"] = firstName;
ViewState["dtTempUserTable"].Rows[rowIndex].Item
["lastName"] = lastName;
// Normal Completion
return true;
}
Now I am receiving the following error reguarding viewstate not
finding the Rows method:
'Object' does not contain a definition for 'rows' and no extension
method 'Rows' accepting a first argument of type 'object' could be
found.
I would like to be able to perform the exact same operation I am doing
in VB.NET in C#. (Without having to move the object to a temporary
datatable object and then back again into viewstate) What am I
missing?
Thanks Before Hand,
Adiel