Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Working with asp.net Repeater control using C# in asp.net 2.0

Author: Zunnair
Download Source Code : 909_aspnet_Repeater.zip

In this simple article you will learn to working with asp.net repeater control

 Create a web application in c#

Drag an asp.net datasource on the form and add new web.config file

Now write connection string in web.config file

<connectionStrings>

<add name="DataConnectionString" connectionString="data source= LAPTOP\SQLDEVELOPER;UID=sa;PWD=lahore;DATABASE=shoppingcart"/>

connectionStrings>

 

Then write code in default.aspx file in form tag

    <div>

        <asp:SqlDataSource ID="DSMobileCategory" runat="server" ConnectionString="<%$ ConnectionStrings:DataConnectionString %>"

            OnSelecting="DSMobileCategory_Selecting" ProviderName="System.Data.SqlClient"

            SelectCommand="SELECT [PID], [Name], [Description], [Model] FROM [SHOPProducts]">asp:SqlDataSource>

   

    div>

 

Now write this code for showing data in datalist control in form tag

<asp:DataList ID="DataList1" runat="server" DataKeyField="PID" DataSourceID="DataSource1">

            <ItemTemplate>

                PID:

                <asp:Label ID="PIDLabel" runat="server" Text='<%# Eval("PID") %>'>asp:Label><br />

                Name:

                <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>'>asp:Label><br />

                Description:

                <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>'>

                asp:Label><br />

                Model:

                <asp:Label ID="ModelLabel" runat="server" Text='<%# Eval("Model") %>'>asp:Label><br />

                <br />

            ItemTemplate>

        asp:DataList>

Now write code on from load event

C#

protected void Page_Load(object sender, EventArgs e)

    {

        try

        {

            Label1.Text = “”;

 

        }

        catch (Exception ex)

        {

            Label1.Text = ex.Message;

        }

    }

VB

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        Try

            Label1.Text = “”

        Catch ex As Exception

            Label1.Text = ex.Message

        End Try

    End Sub

This is simple code for asp.net Repeater control

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Working with asp.net DetailsView control using C# in asp.net 2.0

Disclaimer - Privacy
© 2002-2017 DevASP.net