This article refers to the following Microsoft .NET Framework Class Library namespaces:
- System.Data
- System.Data.SqlClient
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
<%# custID %>
<asp:ListBox id="List1" datasource='<%# myArray %>' runat="server">
<%# ( customer.First Name + " " + customer.LastName ) %>
<%# GetBalance(custID) %>
<asp:textbox id=txt text="<%# custID %>" runat=server />
<%@ Page Language="vb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim cnn As SqlConnection = New SqlConnection("server=(local);" & _
"database=pubs;Integrated Security=SSPI")
Dim cmd As SqlDataAdapter = New SqlDataAdapter("select * from authors", cnn)
Dim ds As DataSet = New DataSet()
cmd.Fill(ds)
Repeater1.DataSource = ds
Repeater1.DataBind()
End Sub
</script>
<html>
<body>
<form id="Form1" method="post" runat="server">
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"au_id") %><br>
</ItemTemplate>
</asp:Repeater>
</form>
</body>
</html>
<%@ Page language="c#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
SqlConnection cnn = new
SqlConnection("server=(local);database=pubs;Integrated Security=SSPI");
SqlDataAdapter da = new SqlDataAdapter("select * from authors", cnn);
DataSet ds = new DataSet();
da.Fill(ds, "authors");
Repeater1.DataSource = ds.Tables["authors"];
Repeater1.DataBind();
}
</script>
<html>
<body>
<form id="WebForm2" method="post" runat="server">
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"au_id") %><br>
</ItemTemplate>
</asp:Repeater>
</form>
</body>
</html>
<%@ Page language="VJ#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
SqlConnection cnn = new SqlConnection("server=(local);database=pubs;Integrated
Security=SSPI");
SqlDataAdapter da = new SqlDataAdapter("select * from authors", cnn);
DataSet ds = new DataSet();
da.Fill(ds, "authors");
DataTableCollection dtc = ds.get_Tables();
int index = dtc.IndexOf("authors");
Repeater1.set_DataSource(dtc.get_Item(index));
Repeater1.DataBind();
}
</script>
<html>
<body>
<form id="WebForm2" method="post" runat="server">
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"au_id") %><br>
</ItemTemplate>
</asp:Repeater>
</form>
</body>
</html>
Dim cnn As SqlConnection = New SqlConnection("server=(local);" & _
"database=pubs;Integrated Security=SSPI")
Dim cmd As SqlDataAdapter = New SqlDataAdapter("select * from authors", cnn)
Dim ds As DataSet = New DataSet()
cmd.Fill(ds)
MyRepeater.DataSource = ds
MyRepeater.DataBind()
SqlConnection cnn = new SqlConnection("server=(local);
database=pubs;Integrated Security=SSPI");
SqlDataAdapter da = new SqlDataAdapter("select * from authors", cnn);
DataSet ds = new DataSet();
da.Fill(ds);
MyRepeater.DataSource = ds;
MyRepeater.DataBind();
SqlConnection cnn = new SqlConnection("server=(local);
database=pubs;Integrated Security=SSPI");
SqlDataAdapter da = new SqlDataAdapter("select * from authors", cnn);
DataSet ds = new DataSet();
da.Fill(ds);
MyRepeater.set_DataSource(ds);
MyRepeater.DataBind();
Dim cnn As SqlConnection = New SqlConnection("server=(local);" & _
"database=pubs;Integrated Security=SSPI")
Dim cmd As SqlCommand = New SqlCommand("select * from authors", cnn)
cnn.Open()
MyRepeater.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)
MyRepeater.DataBind()
SqlConnection cnn = new SqlConnection("server=(local);
database=pubs;Integrated Security=SSPI");
SqlCommand cmd = new SqlCommand("select * from authors", cnn);
cnn.Open();
MyRepeater.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection);
MyRepeater.DataBind();
SqlConnection cnn = new SqlConnection("server=(local);
database=pubs;Integrated Security=SSPI");
SqlCommand cmd = new SqlCommand("select * from authors", cnn);
cnn.Open();
MyRepeater.set_DataSource(cmd.ExecuteReader(CommandBehavior.CloseConnection));
MyRepeater.DataBind();
<%# DataBinder.Eval(Container.DataItem,"au_id") %>
' DataTable as the DataSource
<%# CType(Container.DataItem, System.Data.DataRowView)("au_id") %>
' DataReader as the DataSource
<%# CType(Container.DataItem, System.Data.Common.DbDataRecord)("au_id") %>
' DataReader as the DataSource
<%# CType(Container.DataItem, System.Data.Common.DbDataRecord)(0) %>
// DataTable as the DataSource
<%# ((System.Data.DataRowView)Container.DataItem)["au_id"] %>
// DataReader as the DataSource
<%# ((System.Data.Common.DbDataRecord)Container.DataItem)["au_id"] %>
// DataReader as the DataSource
<%# ((System.Data.Common.DbDataRecord)Container.DataItem)[0] %>
// DataTable as the DataSource
<%# ((System.Data.DataRowView)Container.DataItem)["au_id"] %>
// DataReader as the DataSource
<%# ((System.Data.Common.DbDataRecord)Container.DataItem)["au_id"] %>
// DataReader as the DataSource
<%# ((System.Data.Common.DbDataRecord)Container.DataItem)[0] %>
<asp:repeater id=rptr runat=server>
<itemtemplate>
<asp:label id=lblAuthorID runat=server />
</itemtemplate>
</asp:repeater>
public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
'TODO: Retrieve data from a database,
'and bind the data to a list control.
End Sub
public Sub rptr_OnItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptr.ItemDataBound
Dim rec As DataRowView
rec = e.Item.DataItem
'Make sure that you have the data.
If Not IsDBNull(rec) Then
Dim l1 As Label
l1 = e.Item.FindControl("lblAuthorID")
l1.Text = rec("au_id").ToString()
End If
End Sub
public void Page_Init(object sender, System.EventArgs e)
{
rptr.ItemDataBound += new RepeaterItemEventHandler(rptr_OnItemDataBound);
}
public void Page_Load(object sender, System.EventArgs e)
{
// TODO: Retrieve data from a database,
// and bind the data to a list control.
}
public void rptr_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
System.Data.Common.DbDataRecord rec = (System.Data.Common.DbDataRecord)
e.Item.DataItem;
if(rec!=null) //Make sure that you have the data.
{
Label l1 = (Label)e.Item.FindControl("lblAuthorID");
l1.Text = rec["au_id"].ToString();
}
}
public void Page_Init(Object sender, System.EventArgs e)
{
rptr.add_ItemDataBound(new RepeaterItemEventHandler(rptr_OnItemDataBound));
}
private void Page_Load(Object sender, System.EventArgs e)
{
// TODO: Retrieve data from a database,
// and bind the data to a list control.
}
public void rptr_OnItemDataBound(Object sender, RepeaterItemEventArgs e)
{
System.Data.Common.DbDataRecord rec = (System.Data.Common.DbDataRecord)
e.get_Item().get_DataItem();
if (rec != null) //Make sure that you have the data.
{
Label l1 = (Label)e.get_Item().FindControl("lblAuthorID");
l1.set_Text(((rec.get_Item("au_id")).ToString()));
}
}
Keywords: kbvs2003swept, kbaspwpswept, kbarttyperoadmap, kbdatabinding, kbdsupport, kbinfo, kbservercontrols, kb