HI friends
What is the use of data list in asp.net ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Jan 4, 2012, 11:22 AM
The DataList control is used to display a repeated list of items that are bound to the control. However, the DataList control adds a table around the data items by default. The DataList control may be bound to a database table, an XML file, or another list of items.
Here is an example Display Picture and record In Datalist
First create a table student
Create table student (sid varchar(50),sname varchar(50),saddress varchar(50), smarks int,pic varchar (50))
Store the picture in the program folder and save there name in pic column of the table with there extension like (.gif,.jpg,.bmp)
Default.aspx code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
Default.aspx.vb code
Imports System.Data.SqlClient
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim con As New SqlConnection(strConnString)
Dim com As SqlCommand
Dim str As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
con.Open()
Str = "select * from student"
com = New SqlCommand(Str, con)
Dim reader As SqlDataReader
reader = com.ExecuteReader
DataList1.DataSource = reader
DataList1.DataBind()
reader.Close()
con.Close()
End If
End Sub
End Class
Thanks
VulpesPosted Jan 4, 2012, 11:21 AM
http://msdn.microsoft.com/en-us/library/aa479015.aspx
http://www.c-sharpcorner.com/uploadfile/puranindia/datagrid-and-datalist-controls-in-Asp-Net/