ASP.NET / VB Iterate Through Collection

Jul 7, 2010

[This is a simplified example] I have a collection ("myCollection") in which exists three entries: ("hello", "goodbye", "welcome"). I want to iterate through the collection and if in the collection there is the entry "welcome" I want to take one action, if that entry doesn't exist I want to do something else. Like this (pseudo):

[Code]...

View 1 Replies


ADVERTISEMENT

Iterate Through A Collection Of Structures?

Mar 10, 2009

I have created a collection of structures. Each structure, of course, contains fields.

Lets say something like:
Public Structure clientStructure
Public ID As String
Public firstName As String

[Code]....

How can I access a field of a particular structure using for.... each?

That is, how can I retrieve out of the collection (lets say item 5's) firstName, using for...each?

View 2 Replies

Iterate Over A Collection Of Anonymous Type In .NET

Jun 22, 2011

I'm OK with both C# and VB.NET..I have a function GetListOfBook, that returns LINQ to SQL result that has a collection of objects like the following:[code]

View 4 Replies

Linq Iterate A Control Collection?

Jun 29, 2009

Private Function GetWebDataGridOKButtonId() As String
Dim ctls As ControlCollection = _
WebDataGrid1.Controls(0).Controls(0).Controls

[Code]....

This is not working for me. I am trying to iterate a control collection and return one control ID.

View 2 Replies

Cannot Iterate Of A Collection Of Anonymous Types Created From A LINQ Query?

Mar 17, 2010

Every LINQ example I have seen for VB.NET anonymous types claims I can do something like this:

[code]...

Now when I go to iterate through the collection(see example below), I get an error that says "Name "x" is not declared. For Each x in Infos It's like VB.NET doesn't understand that Infos is a collection of anonymous types created by LINQ and wants me to declare "x" as some type. (Wouldn't this defeat the purpose of an anonymous type?) I have added the references to System.Data.Linq and System.Data.DataSetExtensions to my project. Here is what I am importing with the class:

[code]...

View 4 Replies

.net - Storing Subcollections (filtered Versions Of The Main Collection) Inside The Collection As Cache?

Jan 15, 2010

Is it good practice to store sub-collections of item X inside a parent collection of item X for caching 'filter-queries' which are performed on the parent collection? (They won't be used together (as in color AND type).) Or is it also ok to just Loop over the collection and return the correct entities in a temporary collection?

[Code]...

View 1 Replies

C# - Edit List Collection : Error Note Collection Was Modified - Enumeration Operation May Not Execute?

Sep 7, 2011

I have the following classes:

Product, Service and OrderItem

Product and Service must inherit OrderItem. So basically I want to store OrderItem object in my shopping cart and these object are store in a list.

Public MustInherit Class OrderItem
Private m_enuItemType As TypeOfItem = TypeOfItem.None
Private m_strUserID As Integer[code].....

View 1 Replies

Make A Custom Collection That Take Advantage Of The Collection Editor?

Feb 8, 2010

I have been researching for a couple of days now and to no avail. Does Anyone know how to make a custom collection that take advantage of the collection editor? I would like to be able to have 3 Color Values, 1 Boolean and 1 String.

View 15 Replies

.net - Collection Initializes For Read-only Collection Properties?

Jul 25, 2011

I'm trying to support Basic.NET on my framework so I'm trying to convert C# 4 code to Basic.NET 10. Microsoft is committed to "co-evolve" these two but I'm having a problem with collection initialization... I found that I can initialize a collection much like in C#:

[Code]...

View 6 Replies

.net - Search The Collection Of A Collection In LINQ Where Clause?

Apr 15, 2009

I've got the following ADO.NET Entity Framework Entity Data Model:I want to find all the Policyholders with both a Service of a given Id and also a Keyword of a given Status.

This LINQ Does Not Work:

Dim ServicesId As Integer = ...
Dim KeywordStatus As Integer = ...
Dim FoundPolicyholders = From p As Policyholder In db.PolicyholderSet.Include("Keywords").Include("Services") _
Where p.Services.Id = ServicesId _
And p.Keywords.Status = KeywordStatus _
Select p

The Where clause cannot search the p.Services and p.Keywords EntityCollections in that way.

[Code]...

View 1 Replies

Accessing And Adding Items To A Collection That Is In A Collection?

Apr 6, 2012

currently in my application I have a Global Collection that is a Collection of Collections.Currently I am trying to add items/ elements to one of the child collections of the Global Collection but I am unable to use the collections methods of the child.When I assign a variable to the child collection and return the collection it is just an object with the collection inside.

Ex:
Dim GlobalCollection as New Collection
Dim ChildCollection1 as New Collection
Dim tempCurrentCollection[code]......

View 3 Replies

Collection Index Must Be In The Range 1 To The Size Of The Collection?

Dec 17, 2009

I've been working with a CMS called InsiteCreations 2008. I'm running into an error I just can't wrap my head around. I would even be willing to compensate anyone a small amount over paypal, for a solution. The error is rare in occurance, and appears when clicking about 3-4% of links to other pages within our CMS.The full code page is quite large, but there seems to be only one function associated with the error. The error also only appears when not logged into the CMS. If logged into the CMS, clicking the link simply displays the page as normal. I have already checked permissions on the page from the CMS admin console, and it is public.

The error message is as follows:

Server Error in '/' Application.Collection index must be in the range 1 to the size of the collection.
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.

[code]....

View 2 Replies

Search The Collection Of A Collection In LINQ Where Clause?

Apr 15, 2011

search the collection of a collection in my LINQ Where clause?

View 11 Replies

Asp.net - Iterate Through A DynamicJsonObject

Jan 27, 2012

I'm using a DynamicJsonModelBinder from a blog post to pass my JSON data from JavaScript to my ASP.NET MVC Controller as a DynamicJsonObject.

Have a look at the blog post: [URL]

I converted it for my project to VB.NET : [URL]

Imports System.Dynamic
Imports System.Web.Helpers
Namespace MyNameSpace

[Code]....

This works. In my controller, I can access my jsonObject like this: obj.ID '123

But I haven't got an idea yet how to iterate through all properties. I can get all member names as a IEnumerable String Collection (obj.GetDynamicMemberNames()), but how do I use the TryGetMember method to access the value of a member ?

View 1 Replies

Asp.net - Iterate Through Textboxes In VB Web App?

Aug 15, 2011

I have a VB Web Application with a bunch of textboxes on it in Default.aspx (Using the basic template in Visual Web Designer 2010 Express). I'd like to iterate through those textboxes using some sort of VB solution if at all possible and clear them when the user presses a button. I've tried using something like this:

Dim cControl As Control
For Each cControl in Me.Controls
If cControl Is TextBox Then

[Code].....

View 3 Replies

How To Iterate Through A Group

Jan 15, 2010

I need some help with a LINQ query in VB.Net, please.[code]This works, and returns me the data I need to work with. Now I want to iterate through the groups, using a For Each construct. like this: For Each x In drivers Next...However, the compiler is barking at me, telling me that the "'x' is not accessible in this context because it is 'Friend'."

View 3 Replies

Iterate Controls In WPF?

May 19, 2011

I have a simple XAML file with a grid in it and textboxes. But when using my code it does not find the textboxes by iteration.

VB.Net:

Dim ctl As FrameworkElement = Me.MainWindow

Code:

Dim ChildrenCount As Integer = VisualTreeHelper.GetChildrenCount(ctl)
'ChildrenCount is always zero
For i As Integer = 0 To ChildrenCount - 1
Dim Child As FrameworkElement = VisualTreeHelper.GetChild(ctl, i)

[Code].....

View 3 Replies

Iterate Through A BindingSource?

Jan 31, 2010

I have a BindingSource bound to a DataTable.

I use the BS Filter and would like to iterate the filtered dataset of the DataTable using the Bindingsource.

I know I can do a MoveFirst and the MoveNext and each time using the BS.Position get the correct row in the underlying DataTable. But how do I know when the sets ends? I'm sure there must be such a property, but what is it?

View 2 Replies

Iterate Through A List That Is Nothing

Nov 27, 2010

if I run the following code,For each itm in MyList Next if the list is nothing i got an error..Is there a better way to deal with list=nothing than using a condion like [code]

View 14 Replies

Iterate Through An Equation?

Apr 26, 2012

I want to iterate through an equation and modify a number e.g. Multiply it by 10, where there is one. How do I do this?

View 4 Replies

Iterate Through The Structure?

Mar 26, 2009

I have a structure with types ranging from thread's to control.what im looking for is a easy way to iterate through those item like For eachbut i couldn't get for each to workis there a way to do it

View 1 Replies

Iterate Through XML File?

Dec 15, 2011

I am having trouble looping through the following XML file and returning the proper values at each level.

XML File:
<?xml version="1.0"?>
<Domains>

[code]....

View 3 Replies

.NET LINQ - Count Of Collection Within Collection?

Apr 14, 2011

Take the following scenario:

Public Class Store
Public Overridable Property Areas As List(Of Area)
End Class
Public Class Area

[code]....

What's the quickest way to get a total count of shelves for a store? I.e. for a store I get the total count of areas by using Areas.Count Or will I need to loop through each area and tally the count of shelves?

View 2 Replies

Asp.net - Add Controls To A Collection And Update From Collection

Mar 25, 2011

I have an ASP.NET app with lots of textboxes all over the page that need updating at various points through program execution. These textboxes actually belong to a certain class, so for easy updating I thought I could create a Dictionary(Of string, object) and add the control.ID and the control to it and then for updating do something like this:

[Code]...

View 3 Replies

C# - VB Collection - Convert To A Modern Collection?

Jun 26, 2012

I need to convert a VB Collection to a modern one, like Dictionary or Hashtable. For my approach, I need the Collection's KEYS. Googling tells me that it's impossible. Re-writing the entire application using new collections is not an option as the application is really old and large (converted from VB6 to VB.Net).Using the old Collection also is not good - as there are new components in development.Converting a - for example - Hashtable to Collection works:

using VBCollection = Microsoft.VisualBasic.Collection;
public static VBCollection ToVBCollection(this Hashtable table)
{

[code]....

View 1 Replies

Iterate Through Optionbuttons In A Loop?

May 27, 2010

I am working on MS Excel 2000 form and inside VB code, I want to replace following block of code with a loop.

OptionButton1.Value = True

OptionButton2.Value = True

OptionButton3.Value = True[code]....

post an example of a working code to replace 10 lines below with a loop and still be able to set the OptionButton values iteratively ?

View 2 Replies

.net - How To Iterate Over The Properties Of An Object

Mar 23, 2011

I'm debuging an complex calculation object in my project, and I'd like to show its various and many properties in a textbox, to make my tests easier.

Can I do something like

for each p as someKindOfProperty in MyObject1
debug.print(p.name & " - " & debug.print p.value)
textbox1.text = textbox1.text & vbcrlf & p.name & " - " & p.value
next

View 1 Replies

ASP.NET : Iterate Through Multiline Textbox?

Jul 20, 2011

I'm trying to iterate through each line of a multiline textbox. Something like:

For Each line In Me.txtBox1.Lines
Response.Write line.Text
Next

Is there any neat way to do this, or will I need to write a character-by-character parser and look for carriage returns?

View 4 Replies

C# - Iterate All Properties In The List?

Oct 13, 2010

I have List (Of Report). Report has 90 properties. I dont want write them each and every propertiy to get values for properties. Is there any waht to get propeties values from the List

Ex: Dim mReports as new List(Of Reports) mReport = GetReports()

For each mReport as Report In mReports
'Here I want get all properties values without writing property names
next

View 4 Replies

C# - Iterate All Public Enums?

Nov 22, 2010

We have a common component in our source which contains all the enums (approx 300!) for a very large application.Is there any way, using either C# or VB.NET, to iterate through all of them in order to perform an action on each one?

How to iterate all "public string" properties in a .net class is almost relevant but the enums I am dealing with are a mix of types.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved