Sorry I am not completely sure how to phrase my question, but what I am trying to do is inside a for each loop set the item of a model then set the value of that item.
dim td as new project.model.mymodel //create model object
For each dr as datarow in dt.rows
dim itemName as string = convert.tostring(dr("Field"))
td.itemName = "6"
next
I keep getting an error that itemName is not part of collection td
Any help would be appreciated.
Thanks,
2 Replies - 179 Views - Last Post: 20 June 2012 - 07:06 AM
#1
Is it possible to dynamically set an item in an mvc model
Posted 19 June 2012 - 10:14 AM
Replies To: Is it possible to dynamically set an item in an mvc model
#2
Re: Is it possible to dynamically set an item in an mvc model
Posted 19 June 2012 - 01:36 PM
What exactly is project.model.mymodel?
#3
Re: Is it possible to dynamically set an item in an mvc model
Posted 20 June 2012 - 07:06 AM
_HAWK_, on 19 June 2012 - 01:36 PM, said:
What exactly is project.model.mymodel?
Sorry I was just declaring a mvc model to update the properties.
I found a solution.
I am using the built in funtion CallByName(Object, ProName, CallType, Params) to dynamically set the property values.
So it looks like this:
Dim td as myproject.model.mymodel
For each dr as datarow in dt.rows
CallByName(td, Convert.ToString(dr("Field")), CallType.Set, value)
Next
I found the solution after I figured out the correct wording of my question.
Thanks
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|