Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have designed a Category form, when i click on any category image(imagebutton)  want to redirected on product form with respected product images and information of category.
So for that i want to transfer the category id (value)(i am trying using query string). 
e.g. In Category form, for electronic category, category_id is 1 then all electronics product images must be display on product form.


What I have tried:

[
Design Page Source Code of Category Web Page

]

ASP.NET
<asp:DataList ID="DataList1" runat="server"  RepeatColumns="2" cellspacing="10" 
     CellPadding="4" >
    <ItemTemplate> <%--OnItemCommand="DataList1_ItemCommand"gridlines="Both" ItemStyle-Width="300" ItemStyle-BorderColor="Blue" BorderStyle="Dotted"  
                        BorderColor="Blue" DataSourceID="datasourceid1"--%>
        <br />
    <table border ="0">
        <tr>
            <td>
        <asp:ImageButton runat="server" ID="imgData" ImageUrl='<%# Eval("Value") %>' AlternateText="Image" CommandName="Myimage" 
                         Height="100" Width="100" /> <%--PostBackUrl= '<%#"Product.aspx?cid="+Eval("CategoryID") %>' />--%>
            </td>
        </tr>
        <tr>
             <td align="center">
                    <%# Eval("Text") %>
             </td>
        </tr>
    </table>
        <br />
    </ItemTemplate>
    </asp:DataList>


--------------------------------
[Category form Page Load code to display category images] 


C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string[] filepaths = Directory.GetFiles(Server.MapPath("~/images"));

            List<ListItem> files = new List<ListItem>();
            foreach (string filepath in filepaths)
            {
                string filename = Path.GetFileName(filepath);
                files.Add(new ListItem(filename, "~/images/" + filename));
            }
            DataList1.DataSource = files;
            DataList1.DataBind();
        }
    }
Posted

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