This is some new territory for me but heres what Im trying to figure out.
I have a gridview user control Im using that accepts a Generic List(of myObj). So after I run my Populate, I end up sending my entire object to the gridview. The gridview consumes the object and builds the columns based off the object. Problem is I only want it to use certain fields when I send it. So I put the Required attribute on the fields I want to send.
My question is when I do the Populate of my object and return the object how can I filter only the object properties that have the Required Attribute?
Public Function PopulateWorkItem() As List(Of WorkItem)
Dim db As New DBAccess()
Dim sdr As SqlDataReader = db.ExecuteReader("spGetWorkItemsByWeekId")
Dim wi As New List(Of WorkItem)
wi(wi.Count - 1).ItemID = sdr("ItemID").ToString
wi(wi.Count - 1).WorkDate = FormatDateTime(CDate(sdr("WorkDate")), DateFormat.ShortDate)
wi(wi.Count - 1).Name = sdr("Name").ToString
wi(wi.Count - 1).Street = sdr("Street").ToString
[b] 'When I return this it sends the entire object and I only want to send the properties that I have just queried[/b]
When I set the DataSource of the grid it builds the Columns from the object I send it. So it has "al"l the properties in my object, which it doesnt need, so I am trying to use the Required attribute like this
Public Property Street() As String
Set(value As String)
m_Street = value
So when Im doing my return after the populate how can I filter out just the "Required" fields?
Thanks for any help!!