This tutorial will show you how to store data with ArrayList using ASP.NET 2.0 and VB.NET.
At first, you need to import the namespace from System.Collections. The System.Collections namespace contains classe ArrayList which Implements the IList interface using an array whose size is dynamically increased as required.
| Imports System.Collections |
We migrated our web sites to Server Intellect over one weekend and the setup was so smooth that we were up and running right away. They assisted us with everything we needed to do for all of our applications. With Server Intellect's help, we were able to avoid any headaches!
In order to run the example, we will use the btn_get_Click to trigger the task. The code as following:
| Protected Sub btn_get_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_get.Click Dim name As String = String.Empty End Sub Dim EmployeeList As ArrayList = New ArrayList() name = "Jake" EmployeeList.Add(name) name = "peter" EmployeeList.Add(name) name = "lily" EmployeeList.Add(name) Me.GridView1.DataSource = EmployeeList Me.GridView1.DataBind() |
We moved our web sites to Server Intellect and have found them to be incredibly professional. Their setup is very easy and we were up and running in no time.
The front end StoreDataWithArraylistVB.aspx page looks something like this:| <div align="left" style="text-align: center"> <table> <tr> </table><td colspan="2" style="width: 402px"> </tr><asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal"> <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /> <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> <AlternatingRowStyle BackColor="#F7F7F7" /> </asp:GridView> </td> <tr> <td colspan="2" style="height: 26px; width: 402px;"> </tr><asp:Button ID="btn_get" runat="server" Text="Get data from arraylist" OnClick="btn_get_Click" /></td> </div> |
Need help with Windows Dedicated Hosting? Try Server Intellect. I'm a happy customer!
The flow for the code behind page is as follows| Imports System.Collections Inherits System.Web.UI.Page End Class Protected Sub btn_get_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_get.Click Dim name As String = String.Empty End SubDim EmployeeList As ArrayList = New ArrayList() name = "Jake" EmployeeList.Add(name) name = "peter" EmployeeList.Add(name) name = "lily" EmployeeList.Add(name) Me.GridView1.DataSource = EmployeeList Me.GridView1.DataBind() Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' This tutorial is provided in part by Server Intellect Web Hosting Solutions http://www.serverintellect.com End Sub' Visit http://www.AspNetTutorials.com for more ASP.NET Tutorials |
No comments:
Post a Comment