Manoj Jagdale Ответов: 0

Передача значения после нажатия кнопки imagebutton с помощью строки запроса из одной веб-формы в другую веб-форму


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.


Что я уже пробовал:

[
Design Page Source Code of Category Web Page

]

<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] 


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();
        }
    }

0 Ответов