How to Add / Remove From Collection

Discussion in 'ASP .Net Web Controls' started by Chuck Insight, Feb 27, 2005.

  1. Please Help a Novice with a WEB Form Problem.

    I have discovered that both an Array and an ArrayList can contain a
    collection of 300 integers. The things I cannot seem to figure out are:
    1 - How to populate these objects,
    2 - How to test the members to determine whether they contain a particular
    value,
    3 - How to delete or set to zero the member after it passes the test, and
    4 - How to populate a different Array(List) with the value of the original
    list.


    I have also discovered a few methods within these classes such as .Equals
    ..Add .Remove .GetValue, which seem to hold significant parts of my answer;
    but the book I have falls very short of explaining how to make them work the
    way she indicates.

    I would greatly appreciate any help (or a link to a tutor that shows
    examples) that clearly explains how to deploy these methods.

    Thanks very much,
    Chuck
    Chuck Insight, Feb 27, 2005
    #1
    1. Advertising

  2. Please Help a Novice with a WEB Form Problem (Coded in VB - Sorry, I forgot
    to mention that in my initial post.)

    I have discovered that both an Array and an ArrayList can contain a
    collection of 300 integers. The things I cannot seem to figure out are:
    1 - How to populate these objects,
    2 - How to test the members to determine whether they contain a particular
    value,
    3 - How to delete or set to zero the member after it passes the test, and
    4 - How to populate a different Array(List) with the value of the original
    list.


    I have also discovered a few methods within these classes such as .Equals
    ..Add .Remove .GetValue, which seem to hold significant parts of my answer;
    but the book I have falls very short of explaining how to make them work the
    way she indicates.

    I would greatly appreciate any help (or a link to a tutor that shows
    examples) that clearly explains how to deploy these methods.

    Thanks very much,
    Chuck
    Chuck Insight, Feb 27, 2005
    #2
    1. Advertising

  3. There are quite a few samples on using arraylist. You might want to
    investigate here:

    http://msdn.microsoft.com/library/d...rfsystemcollectionsarraylistclassaddtopic.asp

    BTW, what is the book and name of the author? The author should know that
    the information was insufficient.

    "Chuck Insight" <> wrote in message
    news:JXlUd.68669$tl3.12632@attbi_s02...
    > Please Help a Novice with a WEB Form Problem.
    >
    > I have discovered that both an Array and an ArrayList can contain a
    > collection of 300 integers. The things I cannot seem to figure out are:
    > 1 - How to populate these objects,
    > 2 - How to test the members to determine whether they contain a particular
    > value,
    > 3 - How to delete or set to zero the member after it passes the test, and
    > 4 - How to populate a different Array(List) with the value of the original
    > list.
    >
    >
    > I have also discovered a few methods within these classes such as .Equals
    > .Add .Remove .GetValue, which seem to hold significant parts of my answer;
    > but the book I have falls very short of explaining how to make them work
    > the
    > way she indicates.
    >
    > I would greatly appreciate any help (or a link to a tutor that shows
    > examples) that clearly explains how to deploy these methods.
    >
    > Thanks very much,
    > Chuck
    >
    >
    Ken Cox [Microsoft MVP], Feb 28, 2005
    #3
  4. Hey Chuck,

    It looks like you're taking too many shortcuts. Here's some code that works
    for me. Does it work for you?

    Ken
    Microsoft MVP [ASP.NET]


    <%@ Page Language="vb" AutoEventWireup="true" %>
    <%@ Import namespace="System.Collections" %>
    <%@ Import namespace="Microsoft.VisualBasic" %>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>arraylstscript</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema"
    content="http://schemas.microsoft.com/intellisense/ie5">
    <script runat='server' language="vb">
    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs)

    dim Samples as New ArrayList()
    Samples.Add("1")
    Samples.Add("2")
    Samples.Add("3")
    Samples.Add("4")
    Samples.Add("5")
    Samples.Add("6")
    Samples.Add("7")
    Samples.Add("8")
    Samples.Add("9")
    Samples.Add("10")
    Samples.Add("11")
    Samples.Add("12")
    Samples.Add("13")
    Samples.Add("14")
    Samples.Add("15")
    Samples.Add("16")
    Samples.Add("17")
    Samples.Add("18")
    Samples.Add("19")
    Samples.Add("20")
    Samples.Add("21")
    Samples.Add("22")
    Samples.Add("23")
    Samples.Add("24")
    Samples.Add("25")
    Samples.Add("26")
    Samples.Add("27")
    Samples.Add("28")
    Samples.Add("29")
    Samples.Add("30")

    DropDownList1.DataSource = Samples
    DropDownList1.DataBind()
    end sub

    </script>
    </head>
    <body MS_POSITIONING="FlowLayout">
    <form id="Form1" method="post" runat="server">
    <asp:dropdownlist id="DropDownList1"
    runat="server"></asp:dropdownlist>
    </form>
    </body>
    </html>
    Ken Cox [Microsoft MVP], Mar 1, 2005
    #4
  5. Thanks a 1,000,000 Ken.
    You have officially become my hero.
    Now that I have the hard part in place, I will try to finish the balance of
    my project.


    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:...
    > Hey Chuck,
    >
    > It looks like you're taking too many shortcuts. Here's some code that

    works
    > for me. Does it work for you?
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    >
    >
    > <%@ Page Language="vb" AutoEventWireup="true" %>
    > <%@ Import namespace="System.Collections" %>
    > <%@ Import namespace="Microsoft.VisualBasic" %>
    >
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <html>
    > <head>
    > <title>arraylstscript</title>
    > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    > <meta name="vs_defaultClientScript" content="JavaScript">
    > <meta name="vs_targetSchema"
    > content="http://schemas.microsoft.com/intellisense/ie5">
    > <script runat='server' language="vb">
    > Private Sub Page_Load _
    > (ByVal sender As System.Object, _
    > ByVal e As System.EventArgs)
    >
    > dim Samples as New ArrayList()
    > Samples.Add("1")
    > Samples.Add("2")
    > Samples.Add("3")
    > Samples.Add("4")
    > Samples.Add("5")
    > Samples.Add("6")
    > Samples.Add("7")
    > Samples.Add("8")
    > Samples.Add("9")
    > Samples.Add("10")
    > Samples.Add("11")
    > Samples.Add("12")
    > Samples.Add("13")
    > Samples.Add("14")
    > Samples.Add("15")
    > Samples.Add("16")
    > Samples.Add("17")
    > Samples.Add("18")
    > Samples.Add("19")
    > Samples.Add("20")
    > Samples.Add("21")
    > Samples.Add("22")
    > Samples.Add("23")
    > Samples.Add("24")
    > Samples.Add("25")
    > Samples.Add("26")
    > Samples.Add("27")
    > Samples.Add("28")
    > Samples.Add("29")
    > Samples.Add("30")
    >
    > DropDownList1.DataSource = Samples
    > DropDownList1.DataBind()
    > end sub
    >
    > </script>
    > </head>
    > <body MS_POSITIONING="FlowLayout">
    > <form id="Form1" method="post" runat="server">
    > <asp:dropdownlist id="DropDownList1"
    > runat="server"></asp:dropdownlist>
    > </form>
    > </body>
    > </html>
    >
    Chuck Insight, Mar 1, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dylan
    Replies:
    5
    Views:
    419
    Daniel T.
    Mar 22, 2005
  2. Pradeep
    Replies:
    2
    Views:
    679
    Patricia Shanahan
    Jan 24, 2007
  3. Øyvind Isaksen
    Replies:
    1
    Views:
    965
    Øyvind Isaksen
    May 18, 2007
  4. Chad Scharf
    Replies:
    3
    Views:
    868
    Chad Scharf
    Oct 18, 2007
  5. Hemant

    create collection of collection

    Hemant, Oct 22, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    421
    Gregory A. Beamer
    Oct 22, 2009
Loading...

Share This Page