This example demonstrates how to use IList Generic Interface to store data.
This example demonstrates how to use IList Generic Interface to store data.
IList Generic Interface represents a collection of objects that can be individually accessed by index.
First, you will need to import the System.Collections.Generic namespace.
| Imports System.Collections.Generic; |
The System.Collections.Generic namespace contains interfaces and classes that define generic collections, which allow users to create strongly typed collections that provide better type safety and performance than non-generic strongly typed collections.
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.
We use the BindData function to do the work.We use GridView control to display data. The code as follow:
| Private Sub BindData() Dim userinfos As IList(Of UserInfo) = New List(Of UserInfo) End Sub Dim i As Integer For i = 0 To 4 Dim info As New UserInfo("username" + i.ToString(), "password" + i.ToString()) userinfos.Add(info)Next i Me.GridView1.DataSource = userinfos 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.
I add one userinfo custom class which is used to store data.The code as follow:
| Imports System '/ <summary> '/ UserInfo '/ </summary> Public Class UserInfo Private _userName As String = String.Empty End Class Private _password As String = String.Empty Public Sub New() End Sub Public Sub New(ByVal userName As String, ByVal password As String) Me._userName = userName End SubMe._password = password Public ReadOnly Property UserName() As String Get End PropertyReturn _userName End GetPublic ReadOnly Property Password() As String Get End PropertyReturn _password End Get |
I just signed up at Server Intellect and couldn't be more pleased with my Windows Server! Check it out and see for yourself.
The front end TemplateVB.aspx page looks something like this:| <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal"> <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> </asp:GridView> <Columns> <asp:BoundField DataField="UserName" HeaderText="UserName" /> </Columns><asp:BoundField DataField="Password" HeaderText="Password" /> <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" /> |
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 Imports System.Data Imports System.Configuration Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Imports System.Collections.Generic Partial Class _Default Inherits System.Web.UI.Page End Class Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then End SubBindData() End IfPrivate Sub BindData() Dim userinfos As IList(Of UserInfo) = New List(Of UserInfo) End SubDim i As Integer For i = 0 To 4 Dim info As New UserInfo("username" + i.ToString(), "password" + i.ToString()) Next iuserinfos.Add(info) Me.GridView1.DataSource = userinfos Me.GridView1.DataBind() |
No comments:
Post a Comment