Server Intellect
 
Home   Asp.Net Tutorials   What's New   Newsletter   More Resources
 
 
  Categories
Advanced Technologies
AJAX
Internet Browsers
Controls
Database
Email
Error Handling
File
Graphics
Website Navigation
Network
Performance
User Interface and Themes
Validation
Visual Web Developer
Web Services
XML
Suggest Tutorial


Navigator: Home - Tutorials - Advanced Technologies - Store Data with ArrayList using ASP.NET 2.0 and C#
Store Data with ArrayList using ASP.NET 2.0 and C#


ASP.NET Advanced Technologies Tutorial

This tutorial will show you how to store data with ArrayList using ASP.NET 2.0 and C#.

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.

using System.Collections

We are using Server Intellect and have found that by far, they are the most friendly, responsive, and knowledgeable support team we've ever dealt with!

In order to run the example, we will use the btn_get_Click to trigger the task. The code as following:

protected void btn_get_Click(object sender, EventArgs e)
{
string name = string.Empty;

ArrayList EmployeeList = new ArrayList();
name = "Jake";
EmployeeList.Add(name);
name = "peter";
EmployeeList.Add(name);
name = "lily";
EmployeeList.Add(name);

this.GridView1.DataSource = EmployeeList;
this.GridView1.DataBind();
}

Yes, it is possible to find a good web host. Sometimes it takes a while. After trying several, we went with Server Intellect and have been very happy. They are the most professional, customer service friendly and technically knowledgeable host we've found so far.

The front end StoreDataWithArraylistCsharp.aspx page looks something like this:

<div align="left" style="text-align: center">
&nbsp;<table>
<tr>
<td colspan="2" style="width: 402px">
<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>
&nbsp;</td>
</tr>
<tr>
<td colspan="2" style="height: 26px; width: 402px;">
<asp:Button ID="btn_get" runat="server" Text="Get data from arraylist" OnClick="btn_get_Click" /></td>
</tr>
</table>
&nbsp;&nbsp;
</div>

We chose Server Intellect for its dedicated servers, for our web hosting. They have managed to handle virtually everything for us, from start to finish. And their customer service is stellar.

The flow for the code behind page is as follows

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;

public partial class _Default : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
// This tutorial is provided in part by Server Intellect Web Hosting Solutions http://www.serverintellect.com
// Visit http://www.AspNetTutorials.com for more ASP.NET Tutorials
}

protected void btn_get_Click(object sender, EventArgs e)
{
string name = string.Empty;

ArrayList EmployeeList = new ArrayList();
name = "Jake";
EmployeeList.Add(name);
name = "peter";
EmployeeList.Add(name);
name = "lily";
EmployeeList.Add(name);

this.GridView1.DataSource = EmployeeList;
this.GridView1.DataBind();
}
}

Download the Full Working Version of this Project written with Visual Studio.NET C#.NET 2005 Here!

Looking for the VB.NET 2005 Version? Click Here!

Looking for more ASP.NET Tutorials? Click Here!





 
  Developer Resources







Server Intellect Rocks