Datagrid|datagrid controls [Visual Basic, C #, JScript] The following example shows how to use the DataGrid control to display items from a data source.
[Visual Basic]
<%@ Page language= "VB" autoeventwireup= "True"%>
<%@ Import namespace= "System.Data"%>
<script language= "VB" runat= "Server" >
Function CreateDataSource () as ICollection
Dim DT as New DataTable ()
Dim Dr as DataRow
Dt. Columns.Add (New DataColumn ("IntegerValue", GetType (Int32))
Dt. Columns.Add (New DataColumn ("StringValue", GetType (String))
Dt. Columns.Add (New DataColumn ("Currencyvalue", GetType (Double))
Dim I as Integer
For i = 0 to 8
Dr = dt. NewRow ()
Dr (0) = i
DR (1) = "Item" + i.tostring ()
DR (2) = 1.23 * (i + 1)
Dt. Rows.Add (DR)
Next I
Dim DV as New DataView (DT)
Return DV
End Function ' CreateDataSource
Sub Page_Load (sender as Object, E as EventArgs)
If not IsPostBack Then
' Load This data is only once.
Itemsgrid.datasource = CreateDataSource ()
Itemsgrid.databind ()
End If
End Sub ' Page_Load
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.