本文介绍了如何将数据列表中的图像重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码显示了详细信息....当我单击特定的图像时,它想重定向到特定的页面....

我已经这样了

PostBackUrl =''<%#GetUrl(DataBinder.Eval(Container.DataItem,"Programe_Name"))%>''

后面的代码

Below code shows detail....when i click on particular image it want to redirect to particular page....

i have done like this

PostBackUrl=''<%# GetUrl(DataBinder.Eval(Container.DataItem, "Programe_Name")) %>''

code behind

protected string GetUrl(object Programe_Name)
    {
        return string.Format("~/Teacher_availability.aspx?Programe_Name={0}", Programe_Name);
    }




但是此代码无法正常工作....您可以紧急帮助我吗?


完整代码:







but this code is not working....its urgent can u plz help me thanks


Full code:




<asp:DataList ID="DataList1" runat="server"

DataSourceID="SqlDataSource1" Height="559px" RepeatColumns="3"

Width="807px" onitemdatabound="DataList1_ItemDataBound"

HorizontalAlign="Center" RepeatDirection="Horizontal"

onselectedindexchanged="DataList1_SelectedIndexChanged"><ItemTemplate><asp:Image ID="Image2" runat="server" Height="189px" Width="200px"



PostBackUrl='<%# GetUrl(DataBinder.Eval(Container.DataItem, "Programe_Name")) %>'



ImageUrl='<%# getImagePath(Eval("imagePath").ToString()) %>'  /><br /><asp:Label

ID="Courses_NameLabel" runat="server" Text='<%# Eval("Programe_Name") %>' /><br /><asp:Label

ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />&nbsp;<br /> <asp:Hyperlink ID="viewdetailLabel" runat="server"

NavigateUrl='<%# Eval("Programe_Name", "Teacher_availability.aspx?Programe_Name={0}") %>'>See More</asp:Hyperlink><br /><br /></ItemTemplate></asp:DataList>

推荐答案


<asp:datalist id="DataList1" runat="server" datasourceid="SqlDataSource1" height="559px" repeatcolumns="3" width="807px" onitemdatabound="DataList1_ItemDataBound" xmlns:asp="#unknown">
HorizontalAlign="Center" RepeatDirection="Horizontal"
onselectedindexchanged="DataList1_SelectedIndexChanged">
    <itemtemplate>
        <asp:image id="Image2" runat="server" height="189px" width="200px" postbackurl="<%# "Teacher_availability.aspx?Programe_Name=" + Eval("Programe_Name")%>" imageurl="<%# getImagePath(Eval("imagePath").ToString()) %>" />
        <br />
        <asp:label id="Courses_NameLabel" runat="server" text="<%#Eval("Programe_Name") %>" />
        <br />
        <asp:label id="DescriptionLabel" runat="server" text="<%# Eval("Description") %>" />
        <br />
        <asp:hyperlink id="viewdetailLabel" runat="server">
NavigateUrl='<%# Eval("Programe_Name", "Teacher_availability.aspx?Programe_Name={0}") %>'>See More</asp:hyperlink><br />
        <br />
    </itemtemplate>
</asp:datalist>




--Amit




--Amit


这篇关于如何将数据列表中的图像重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 14:29