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"> <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> |
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; 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(); |
No comments:
Post a Comment