Bind the Repeater By the help of LINQ Conding

K011gusain89
Posted by K011gusain89 under LINQ category on | Points: 40 | Views : 1112
Html Code
<div>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="lb1" runat="server" Text='<%#Eval("comment") %>'></asp:Label><br />

<%--<asp:BulletedList ID="list1" runat="server" DataSource='<%#Eval("tb_comments")%>' DataTextField="comments" DisplayMode="Text"></asp:BulletedList>--%>

<asp:DataList ID="dt1" runat="server" DataSource='<%#Eval("tb_comments")%>'>
<ItemTemplate>
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <asp:Label ID="lb2" runat="server" Text='<%#Eval("comments") %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
<asp:TextBox ID="text1" runat="server"></asp:TextBox><br />
</ItemTemplate>
</asp:Repeater>
</div>


C# Coding



DataClasses1DataContext db = new DataClasses1DataContext();
protected void Page_Load(object sender, EventArgs e)
{
//Label1.Text = Request.QueryString[0].ToString();

db.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];

var allcomment = from status in db.tb_status
orderby status.statusid
select new { status.comment, status.tb_comments };
Repeater1.DataSource = allcomment;
Repeater1.DataBind();
}

Comments or Responses

Login to post response