Click here to Skip to main content
15,921,694 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i've following code in aspx page
----------------------------
<ul id="slider1" class="multiple">
                                        <li>
                                    <asp:DataList ID="DataList2" runat="server"  RepeatDirection="Horizontal" RepeatLayout="Table" >
                                        
                                        <itemtemplate>
                                       
                                            <table border="0" cellspacing="0" cellpadding="0">
                                                 <tr>
                                                     <td align="center">
                                                     
                                                          <asp:Image ID="Image1" runat="server" width="125" height="108" class="border1" ImageUrl='<%#"~/Images/Off_Image" + Eval("OffImg") %>'/>
                                                           
                                                     </td>
                                                 </tr>
                                                <%-- <tr>
                                                      <td align="center" class="tital">
                                                           
                                                <%#DataBinder.Eval(Container.DataItem, "Prod_Name")%>
                                                       </td>
                                                  </tr>
                                                  <tr>
                                                       <td align="center">
                                                           
                                                        <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~images1/more_info.jpg" style="border-width:0px;"/>
                                                        </td>
                                                  </tr>--%>
                                                   
                                             </table>
                                             
                                        </itemtemplate>
                                         
                                    
                                   </li>
                                </ul> 
                                            <script type="text/javascript">
    $(document).ready(function(){
        $('#slider1').bxSlider();
    });
</script>         

--------------
And in head tag i've

<head  runat="server">
    <title>Untitled Page</title>
    <script src="jquery.bxSlider.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="bx_styles/bx_styles.css" type="text/css" /> 
	<script src="jquery-latest.js" type="text/javascript"></script> 
	<script src="jquery.bxSlider.js" type="text/javascript"></script> 
	
	<script type="text/javascript"> 
		$(document).ready(function(){
			$('#slider1').bxSlider();
		});
	</script> 
</head>
--------------
the actual problem is when i bound datalist all the images shown but i only want to disply some fixed slied for that wht can i do..
please answer.. thankx
Posted
Updated 16-Mar-16 9:52am
v2

1 solution

try this
 <asp:datalist id="ItemsList" onitemdatabound="Item_Bound" runat="server">
 <itemtemplate>
 <asp:image id="Image1" runat="server" />
</itemtemplate>


On Item_Bound event you can control data binding dynamically
void Item_Bound(Object sender, DataListItemEventArgs e)
     {
        if (e.Item.ItemType == ListItemType.Item ||
            e.Item.ItemType == ListItemType.AlternatingItem)
        {
          // DataRowView drv = (DataRowView)(e.Item.DataItem);
           YourDataSourceClass obj= (YourDataSourceClass )(e.Item.DataItem);
           Image img= (Image)e.Item.FindControl("Image1");
           //if(your condition if need)
           img.ImageUrl=obj.ImageUrl;
        }
     }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900