Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataList with hyperlink and label from arraylists 1

Status
Not open for further replies.

Programming2007

Programmer
Nov 10, 2006
24
US
I am using a DataList to display a list of hyperlinks and labels. A user enters a search criteria and the page (hyperlink) is displayed along with a sentence (label)where the keyword is used. I have a Files arraylist of hyperlinks and a Descriptions arrayList of sentences. I don't know how to get this to work.



Here is my webForm1.aspx

<asp:datalist id="DataList1" runat="server">
<ItemTemplate>
<asp:HyperLink id=hypLocation runat="server" NavigateUrl="<%# Container.DataItem %>" text="<%# Container.DataItem %>">
</asp:HyperLink>
<asp:Label id=lblDescription runat="server" Visible="true" text="<%# Container.DataItem %>">
</asp:Label>
</ItemTemplate>
</asp:datalist>

Here is my WebForm1.vb

Descriptions.Add(strDescription)
DataList1.DataSource = Descriptions
DataList1.DataBind()
allFiles(inttemp) = (allFiles(inttemp).Replace("C:\SCoutline4", "allFiles(inttemp) = allFiles(inttemp).Replace("\", "/")
Files.Add(allFiles(inttemp))
DataList1.DataSource = Files
DataList1.DataBind()

I also tried the following and it didn't work

<asp:datalist id="DataList1" runat="server">
<ItemTemplate>
<asp:HyperLink id=hypLocation runat="server" NavigateUrl="<%#DataBinder.Eval(Container.DataItem,"Files") %>" text="<%#DataBinder.Eval(Container.DataItem,"Files") %>">
</asp:HyperLink>
<asp:Label id=lblDescription runat="server" Visible="true" text="<%#DataBinder.Eval(Container.DataItem,"Descriptions") %>">
</asp:Label>
</ItemTemplate>
</asp:datalist>

Here is my WebForm1.vb
Function getWebViewFiles(ByVal s As String()) As ICollection
Descriptions.Add(strDescription)
allFiles(inttemp) = (allFiles(inttemp).Replace("C:\SCoutline4", "allFiles(inttemp) = allFiles(inttemp).Replace("\", "/")
Files.Add(allFiles(inttemp))
DataList1.DataSource = getWebViewFiles(allFiles)
DataList1.DataBind()
 
hi,

i am confused as to what exactly you are trying to do:

Descriptions.Add(strDescription)
DataList1.DataSource = Descriptions
DataList1.DataBind()
allFiles(inttemp) = (allFiles(inttemp).Replace("C:\SCoutline4", "allFiles(inttemp) = allFiles(inttemp).Replace("\", "/")
Files.Add(allFiles(inttemp))
DataList1.DataSource = Files
DataList1.DataBind()



why are you binding twice???

Known is handfull, Unknown is worldfull
 
Hello I am writing my own site Search for my website. I am opening all the files with .htm and aspx extensions, reading these files and searching for a keyword that a user types in for search criteria textbox.Descriptions is an arraylist that contains the first few words of a sentence where the keyword is located in the .aspx or .htm files. This is so that the user can see a breif description of where their keyword is in a page. The other arraylist is files. This contains the file path where the file is located that contains the keyword that the user is searching for. The path C:\\folderName is replaced with a so that the user can use the files arraylist as a hyperlink to navigate to where the page is that has the keyword.

I used a datalist to display the hyperlinks as files and descriptions as a label. This would look similar to google's search engine where a hyperlink is displayed along with a description of the sentence that the keyword is displayed in.

My problem is that I don't know how to add the descriptions arraylist to the labels in the datalist and also add the corresponding files arraylist to the hyperlinks in the datalist. Any help would be great....
 
the link and description MUST be in the same data source.

otherwise one will override the other. therefore both the description and link must be set in the same arrya. have a multidimensionaly array if you must...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top