深入浅出ASP.NET程序设计-源代码 书籍语言: 简体中文 书籍类型: 程序设计 授权方式: 免费软件 书籍大小: 627 KB

源代码在线查看: ch16-05-01.aspx

软件大小: 628 K
上传用户: bandagemaster
关键词: 书籍 ASP 627 NET
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				
				
				
				
				Ch16-05-01.aspx 使用DataList控件显示记录
				
				' 在这里设置联机字符串的内容
				Sub Page_Load(Obj As Object, e As EventArgs)
				If Not IsPostBack Then
				GetDataSource()
				End If
				End Sub
				Sub GetDataSource()
				Dim DSN As String
				Dim tSQL As String = "Select * From UserDatas"
				Dim OBJConn As OleDbConnection
				DSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
				     Server.MapPath("/ASP/chap14/ASP.NET网页数据库.mdb") & ";"
				OBJConn = New OleDbConnection(DSN)
				OBJConn.Open()
				Dim OBJCmd As OleDbCommand = New OleDbCommand(tSQL, OBJConn)
				DataListCTL.DataSource = OBJCmd.ExecuteReader()
				DataListCTL.DataBind()
				OBJConn.Close()
				End Sub
				Sub DataList_ItemCommand(Obj As Object, E As DataListCommandEventArgs)
				DataListCTL.SelectedIndex = E.Item.ItemIndex
				Label1.Text = "用户编号:" & _
				     DataListCTL.DataKeys.Item(E.Item.ItemIndex).ToString()
				GetDataSource()
				End Sub
				
				
				
				
				使用DataList控件显示记录
				
								     HeaderStyle-BackColor = "#80F0F0"
				     SelectedItemStyle-BackColor = "#4040FF"
				     SelectedItemStyle-ForeColor = "#FFFF00"
				     GridLines = "Both"
				     RepeatLayoyut = "Table"
				     RepeatColumns = "5"
				     RepeatDirection = "Vertical"
				     DataKeyField = "UID"
				     OnItemCommand = "DataList_ItemCommand">
				
				单击用户姓名即可显示详细数据
				
				
								     Text=''
				     CommandName = "UserSelected" />
				
				
				
				
				
				
				
				
				
				
				
				
				
				
							

相关资源