Tuesday 17 January 2012

How to Bind Data List With Product Images From Database




How to Bind With Data List:



<asp:DataList ID="DlProducts" runat="server" Height="138px" Width="416px" Font-Names="Verdana" Font-Size="Small">
   

 <ItemTemplate>
    <div style="border:1px solid black;" id ="divProd" runat=server>
        <table style="width: 550px">
        <tr align =left>
            <td rowspan="4" style="width: 126px;border:0px;" align =left>
                <asp:Label ID="LblProdId" runat ="server" CssClass="LabelStyle" Text='<%# DataBinder.Eval(Container.DataItem, "Product_id") %>' Width="200px" Font-Bold =true Visible=false ></asp:Label>
                <asp:Image ID="Img" runat="server" Height="60px" ImageUrl='<%# "Picture.aspx?id=" & Eval("Product_id")%>' Width="70px" />
               
                </td>
            <td style="width: 224px">
                        <asp:Label ID="ProdName" runat ="server" CssClass="LabelStyle" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>' Width="200px" Font-Bold =true></asp:Label></td>
            <td style="width: 102px">
                            <asp:Label ID="LblQty" runat="server" Font-Names="Verdana" Font-Size="Small" Text="Quantity" Visible=false></asp:Label>
                            <asp:Label ID="LblWeight" runat="server" Font-Names="Verdana" Font-Size="Small" Text="Select Weight"></asp:Label>
                            </td>
            <td>
                            <asp:TextBox ID="txtqty" runat="server" Width="64px" Height=14px Text = "1" style="text-align:right;" OnTextChanged="txtqty_TextChanged" AutoPostBack="True" Visible =false></asp:TextBox>
                            <asp:DropDownList ID="DdlWeight" runat="server" Width = 70px Height = 19px  AutoPostBack ="true" OnSelectedIndexChanged ="DdlWeight_SelectedIndexChanged"
                               
                                DataSource = '<% #DdlBindWeight(Eval("Product_id"))%>' DataValueField = "data_id" DataTextField = "data"
                                Font-Size="12px" CssClass = "SetIndex"></asp:DropDownList>
                            </td>
        </tr>
        <tr>
            <td style="width: 224px">
                        <asp:Label ID="lblAmount" runat ="server" CssClass="LabelStyle" Text='<%# DataBinder.Eval(Container.DataItem, "Sales_Price") %>' Width="200px"></asp:Label>
                        <asp:Label ID="CalAmt" runat ="server" CssClass="LabelStyle" Text='<%# DataBinder.Eval(Container.DataItem, "Price") %>' Width="200px" Visible =false></asp:Label>
                        </td>
            <td style="width: 102px">
            </td>


        </tr>
        <tr>
            <td style="width: 224px; height: 21px">
                        <asp:Label ID="Label3" runat ="server" CssClass="LabelStyle" Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>' Width="200px"></asp:Label></td>
            <td style="width: 102px; height: 21px">
            </td>
            <td style="height: 21px">
            </td>
        </tr>
        <tr>
            <td style="width: 224px">
            </td>
            <td style="width: 102px">
            </td>
            <td>
            </td>
        </tr>
    </table>             
          
</div>
 </ItemTemplate>
       
</asp:DataList>

No comments:

Post a Comment