Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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:




XML
<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>
Posted

I guess you meant to tag this 'ASP.NET' and didn't ?

It's not urgent, in fact, while we're happy to help, if your job gets done has no bearing on our lives at all.

You do not define 'not working' so it's very hard to offer concrete help. An example of the URLs you get would be hugely helpful. The ~ is not part of a well formed client side URL, it's something .NET uses to make a URL that starts at the root. Remove it. Also cast your object to string, just to be sure. Then, if it doesn't work, try to give us some more information, like what the URL looks like, what you want it to look like, and what goes wrong when you click it.
 
Share this answer
 
Hi,
Try this:
ASP.NET
<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
 
Share this answer
 
Comments
ANOOP CL NAIR 2-Aug-12 0:33am    
i use image button instead of image....thank you very much
_Amy 2-Aug-12 0:33am    
Welcome.. :)

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