programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Thursday, February 19, 2015

How to bind asp datalist control dynamically in

How to bind asp datalist control dynamically in

in this post  we are try  discuss how we can implement this application that displays the employee details, like code, name, and the individual's photo. We need an Image control that we will use inside the ItemTemplate of the DataList control in use. Here is how you can use the Image control.

ItemTemplate of the DataList :

<img src='<# DataBinder.Eval(Container.DataItem, "EmpName") %>.png' style="height:100px;width:100px;border:1px solid gray;"/>
Note that all the images have a primary name corresponding to the employee's name with a .png extension. The complete source code of the DataList control in your .aspx fi le would be similar to what follows: 
<asp:DataList ID="DataList1" runat="server" RepeatColumns="2" RepeatDirection="Horizontal">
                             <table id="Table1" cellpadding="1" cellspacing="1" visible ="true">
                                            <td width="50px">
                                            <p align="left">
                                                  <asp:Label ID="lblEmpCode" runat ="server" CssClass="LabelStyle" Text='
                                                           <%# DataBinder.Eval(Container.DataItem, "EmpCode")%>'>
                                            <td width="200px">
                                            <p align="left">
                                                      <asp:Label ID="lblEmpName" runat = "server"< BR >                                                            CssClass="LabelStyle" Text='
                                                            <%# DataBinder.Eval(Container.DataItem, "EmpName")%>'>
                                            <td width="100px">
                                            <p align="left">
                                                      <img src= '<%#DataBinder.Eval(Container.DataItem, < BR>                                                                   "EmpName") %>.png'
                                                                  style="height:100px;width:100px;border:1px solid gray;"/>

Note the use of the properties RepeatColumns and RepeatDirection in this code snippet. While the former implies the number of columns that you would like to display per record in the rendered output, the later implies the direction of the rendered output, that is, horizontal or vertical.

Other Related Post :

No comments:

Post a Comment