DATABINDING WITH REPEATER CONTROL IN ASP.NET WITH C#.

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
C#  ASP.Net 
 827  View(s)
Ratings:
Rate this:
i am unable to bind data in Repeater control asp.net . how to do this please give me solution.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: Databinding with Repeater control in asp.net with C#.

    A Repeater is a Data-bound control. Data-bound controls are container controls. It creates a link between the Data Source and the presentation UI to display the data. The repeater control is used to display a repeated list of items. It is server side control in asp.net.

    <asp:Repeater ID="Repeater1" runat="server">

    <HeaderTemplate>

    <table style="border: 1px solid #df5015; width: 500px" cellpadding="0">

    <thead>

    <tr style="background-color: #df5015; color: White">

    <th style="padding-left:10px;">ID

    </th>

    <th>Name

    </th>

    <th>Salary

    </th>

    </tr>

    </thead>

    </HeaderTemplate>

    <ItemTemplate>

    <tbody style="background-color: #EBEFF0; border-top: 1px dotted #df5015; width: 500px">

    <tr style="background-color: #EBEFF0">

    <td style="padding-left:10px;">

    <%#Eval("Emp_ID") %>

    </td>

    <td>

    <%#Eval("Emp_Name") %>

    </td>

    <td>

    <%#Eval("Emp_Sal") %>

    </td>

    </tr>

    </tbody>

    </ItemTemplate>

    <FooterTemplate>

    </table>

    </FooterTemplate>

    </asp:Repeater>

     

    string constr = ConfigurationManager.ConnectionStrings["forumConnectionString"].ToString();

    // connection string

    SqlConnection con = new SqlConnection(constr);

     

     

    con.Open();

    SqlCommand com = new SqlCommand("select *from Employee", con); // table name

    SqlDataAdapter da = new SqlDataAdapter(com);

    DataSet ds = new DataSet();

    da.Fill(ds); // fill dataset

    Repeater1.DataSource = ds.Tables[0]; //set DataSource Repeater

    Repeater1.DataBind(); //binding Repeater

     

     

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!