Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can you redirect to a multiple pages using a datalist

Posted on 2007-04-02
4
Medium Priority
?
660 Views
Last Modified: 2008-02-01
Hi,
I have a page with hyperlinks inside a datalist which are working fine.
In a code behind page I have the following code:

<asp:datalist id="dlReports" style="Z-INDEX: 102; LEFT: 376px; POSITION: absolute; TOP: 200px"
Font-Names="Verdana" Width="224px" Font-Name="Arial" CellSpacing="2" CellPadding="2" GridLines="none" Runat="server"
Font-Size="X-Small">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:HyperLink runat="server" NavigateUrl ='<%#"Page1.aspx?ReportDate=" & DataBinder.Eval(Container.DataItem, "ReportDate", "{0:MM/dd/yyyy}").ToString() & "&Flag=" & DataBinder.Eval(Container.DataItem, "CompleteFlag") %>' ID="Hyperlink1">
<%#DataBinder.Eval(Container.DataItem, "ReportName")%>
</asp:HyperLink>
</ItemTemplate>
</asp:datalist>

But now I am trying to add another page - Page2.aspx to the same datalist but I am not sure how I can do this...
I think by running a sql statement -- I could check if my report date >= '02/23/2005' then I would want it
to go to Page2 else all other reports <= '02/23/2005'  to go to Page1...

ReportList.aspxb
Report_03/02/2005  <- hyperlink   (Page2.aspx)
Report_02/23/2005   (Page2.aspx)    
Report_02/16/2005   (Page1.aspx)  
Report_02/09/2005   (Page1.aspx)      
Report_02/02/2005   (Page1.aspx)

Could anyone help me...
Thanks!
0
Comment
Question by:avi4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Accepted Solution

by:
viveksg earned 2000 total points
ID: 18841501
If u want to change the URL dynamically, better do it in server side (itemdatabound event).
Placea literal control instead of HyperLink control and manipulate it in itemdatabound.
ASPX PAGE
========
<asp:datalist id="dlReports" style="Z-INDEX: 102; LEFT: 376px; POSITION: absolute; TOP: 200px" Font-Names="Verdana" Width="224px" Font-Name="Arial" CellSpacing="2" CellPadding="2" GridLines="none" Runat="server"
Font-Size="X-Small">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:Literal runat="server" ID="Literal1" Runat=''Server'>
<%#DataBinder.Eval(Container.DataItem, "ReportName")%>
</asp:HyperLink>
</ItemTemplate>
</asp:datalist>

C# PAGE
======
private void dlReports_ItemDataBound(object sender, DataListItemEventArgs e)
{
  if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==  
  ListItemType.SelectedItem || e.Item.ItemType == ListItemType.AlternatingItem)
 {
     Literal myLiteral = (Literal)e.Item.FindControl("Literal1");
     if (report_date >= '02/23/2005' )
           myLiteral.Text = "<a href='Page2.asp'>Click Here</a>";
    else
           myLiteral.Text = "<a href='Page1.asp'>Click Here</a>";
 }
}
0
 
LVL 1

Expert Comment

by:prabhuyogi
ID: 23303961
how i can split specify mutiple pages for the datalist .i dont understand if any idea


Thanks

Prabhu.M
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question