Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
<asp:DataList ID="DataList1" runat="server" DataKeyField="ProductID" 
        DataSourceID="SqlDataSource1" onitemdatabound="use" BackColor="White" 
        EmptyDataText="Please Select Category."
           BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
           GridLines="Horizontal" RepeatColumns="3" RepeatDirection="Horizontal" 
        Height="534px" Width="726px" style="text-align: center; color: #000000;" OnItemCommand="DataList1_ItemCommand">
        <AlternatingItemStyle BackColor="White" />
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <ItemStyle BackColor="White" ForeColor="#4A3C8C" />
         <ItemTemplate>
            <asp:ImageButton ID="btnFileImg" runat="server" Height="150px" Width="100px" ImageUrl='<%# Eval("filename") %>'  PostBackUrl='<%# Eval("ProductID", "ProductDetails.aspx?ProductID={0}") %>' />
            <asp:Label ID="ImageUrlLabel" runat="server" Text='<%# Eval("filename") %>' Visible="False"></asp:Label><br />
    <br />
            <a href='ProductDetails.aspx?productID=<%# Eval("ProductID") %>' style="font-size: 15px; color: black">
            <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("productName") %>'/><br />
            </a>
            Price: 
            <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("price") %>' />

        </ItemTemplate>
        <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
    </asp:DataList>


This is my Textbox and Button


C#
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
    <asp:Button ID="btnSearch" runat="server" Text="Search" />


This is what I want to do.
DATALIST:

LIST OF PRODUCTS

Textbox search: Samsung Galaxy S4
When button click datalis shows:

Datalist:
Product ID: 2424(<-- example)
Product Name: Samsung Galaxy S4
Description: Blah blah blah....
Price: $300(<- example)
Stock: 5(<-- example)


Thanks in advance
Posted
Updated 18-Feb-14 23:29pm
v2

1 solution

Hi,
When you bind the data to datalist, copy the data in viewstate and then when user searches the data, take from the viewstate and display.
 
Share this answer
 

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