> Dim result_0 = > From col_Row In db.Masters, z In db.DocumentTypes > Select > ListCol = > VendorID = col_Row.VendorID, > Vendor_Name = col_Row.Vendor_Name, >... > Dim TheList = result_0.ToList() > > ' the following line filters results based on user permissions > Dim result_Match = (From x In TheList Where x.SecurityCode.IncludesAnyOf(UserPermissions) Select x).ToList() >>
> Dim NewDT As DataTable = ToDataTable(Me.MyGridView1.DataSource As List (of ListCol)) >>
>> Dim db = New DataClassesDataContext() >> Dim result_0 = >> From col_Row In db.Masters, z In db.DocumentTypes >> Select >> ListCol = >> VendorID = col_Row.VendorID, >> Vendor_Name = col_Row.Vendor_Name, >>... >> If String.IsNullOrWhiteSpace(Me.Project.Text) = False And Me.Project.Text <> "0000" Then >> result_0 = result_0.Where(Function(f) f.Project_ID.ToLower = Project.Text.ToLower) >> End If >>... >> Dim TheList = result_0.ToList() >> >> ' the following line filters results based on user permissions >> Dim result_Match = (From x In TheList Where x.SecurityCode.IncludesAnyOf(UserPermissions) Select x).ToList() >> >> ' populate the gui items >> If result_Match.Count() > 0 Then >> MyGridView1.DataSourceID = "" >> MyGridView1.DataSource = result_Match >> 'MyGridView1.DataKeyNames = "Doc_ID,DocLocation" >> MyGridView1.DataBind() >> MyGridView1.SelectedIndex = 0 >> Dim args As New GridViewRowClickedEventArgs(MyGridView1.Rows(0)) >> Me.Doc_Count.Text = "Your Search has returned " & result_Match.Count().ToString & " documents." >> GridView1_RowClicked(MyGridView1, args) >> endif>>
>>... >> Dim NewDT As DataTable = ToDataTable(Me.MyGridView1.DataSource) >> ' >> Dim i As Integer = 0 >> Do While (i < NewDT.Rows.Count) >> ' build exported data file >> For Each li In NewDT.Rows(i).ItemArray >> DataLine.Add(NewDT.Rows(i).Item(li.value).ToString.Trim) >> Next >> strData += DataLine.ToString + vbCrLf >> ' >> i = (i + 1) >> Loop >> >>... >> >> Public Shared Function ToDataTable(ByVal data As IList(Of T)) As DataTable >> Dim props As PropertyDescriptorCollection = TypeDescriptor.GetProperties(GetType(T)) >> Dim table As DataTable = New DataTable >> Dim n As Integer = 0 >> Do While (n < props.Count) >> Dim prop As PropertyDescriptor = props(n) >> table.Columns.Add(prop.Name, prop.PropertyType) >> n = (n + 1) >> Loop >> Dim values() As Object = New Object((props.Count) - 1) {} >> For Each item As T In data >> Dim x As Integer = 0 >> Do While (x < values.Length) >> values(x) = props(x).GetValue(item) >> x = (x + 1) >> Loop >> table.Rows.Add(values) >> Next >> Return table >> End Function >>>>