Home > DeveloperSection > Forums > Databinding with Repeater control in asp.net with C#.
Ankit Singh

Total Post:341

Points:2389
Posted on    October-30-2015 11:27 PM

 .NET C#  ASP.Net 
Ratings:


 1 Reply(s)
 379  View(s)
Rate this:
i am unable to bind data in Repeater control asp.net . how to do this please give me solution.


aditya kumar Patel

Total Post:242

Points:1722
Posted on    October-30-2015 11:49 PM

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

 

 


Don't want to miss updates? Please click the below button!

Follow MindStick