?
Solved

How do I make information I pull from my database show up as links to show more information?

Posted on 2011-10-19
13
Medium Priority
?
294 Views
Last Modified: 2012-05-12
Hello. I have a page where I'm using a listview control to pull events from my database. I'm only pulling certain information to show up. I have the event name as a linkbutton and I would like for the user to be able to click the name of the event and more information about the event display. So when the event name is clicked I would like to pull the information from the rest of the fields in the database and have them display.  Below is the function and the listview:

Protected Sub lv_MoreInfo(sender As Object, e As ListViewCommandEventArgs)
       
        If (e.CommandName = "Select") Then
            Dim btn As LinkButton = e.CommandSource
            Dim find As String = btn.Text
            Dim dataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
            Dim dataItemIndex As Integer = dataItem.DataItemIndex
            Dim eventID As Integer = lv.DataKeys(dataItemIndex).Value
           
            Dim sql As String = "SELECT * " & _
                            "FROM [Event] " & _
                            "WHERE eventID = " & eventID
           
            lblename.Text = eventID
            lblename.Visible = True
        End If
    End Sub


<asp:ListView ID="lv" runat="server" DataKeyNames="EventID" OnItemDeleting="lv_ItemDeleting" OnItemCommand="lv_MoreInfo">
  <LayoutTemplate>
    <table border="1" cellpadding="1" cellspacing="1" width="100%">
      <tr>
        <th align="left"><asp:Label runat="server" ID="lblEventName">Event Name</asp:Label></th>
        <th align="left"><asp:Label runat="server" ID="lblEventDate">Date</asp:Label></th>
        <th align="left"><asp:Label runat="server" ID="lblEventLocation">Location</asp:Label></th>
        <th align="left"><asp:Label runat="server" ID="lblEventTime">Time</asp:Label></th>
        <th align="left"><asp:Label runat="server" ID="lblEventCost">Cost</asp:Label></th>
      </tr>
      <tr id="itemPlaceholder" runat="server"></tr>
     </table>
   </LayoutTemplate>
   <ItemTemplate>
    <tr runat="server">
     <td><asp:LinkButton runat="server" ID="lnkEvent"><%#Eval("eventName")%></asp:LinkButton></td>
     <td><asp:label runat="server" ID="lblDate"><%#Eval("Date")%></asp:label></td>
     <td><asp:label runat="server" ID="lblLocation"><%#Eval("Location")%></asp:label></td>
     <td><asp:label runat="server" ID="lblTime"><%#Eval("Time")%></asp:label></td>
     <td><asp:Label runat="server" ID="lblCost"><%#Eval("Cost")%></asp:Label></td>
     <td align="left"><asp:Button ID="btnDeleteEvent" runat="server" Text="Delete Event" CommandName="Delete" /></td>
    </tr>
    </ItemTemplate>
    <SelectedItemTemplate>
     <tr class="selectedItem" runat="server">
      <td><asp:LinkButton runat="server" ID="lnkEvent" CommandName="Select"> <%#Eval("eventName")%></asp:LinkButton></td>
      <td><asp:label runat="server" ID="lblDate"><%#Eval("Date")%></asp:label></td>
      <td><asp:label runat="server" ID="lblLocation"><%#Eval("Location")%></asp:label></td>
      <td><asp:label runat="server" ID="lblTime"><%#Eval("Time")%></asp:label></td>
      <td><asp:Label runat="server" ID="lblCost"><%#Eval("Cost")%></asp:Label></td>
    </tr>
    </SelectedItemTemplate>
</asp:ListView><br /><br />
0
Comment
Question by:cdlciddit
  • 8
  • 4
13 Comments
 
LVL 27

Accepted Solution

by:
nmarun earned 1000 total points
ID: 36994439
0
 

Author Comment

by:cdlciddit
ID: 36995096
Thanks. I'm reading through the links you sent now.
0
 

Author Comment

by:cdlciddit
ID: 37002454
Thanks for the links above. Although helpful it doesn't solve my problem. I don't want to change anything about how mine looks. Just want make the event names into links that when clicked more information can be displayed. For instance. Right now I'm only displaying 5 columns of information. When the event name is clicked I want to display the rest of the columns that are in the database that contain more information.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37002461
> I want to display the rest of the columns

How? On a separate page?
0
 

Author Comment

by:cdlciddit
ID: 37027271
Well. It doesn't really matter to me. I was thinking I could make a panel visible and have the information appear there. But if having it appear on a seperate page is easier I have no problem with that.
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 1000 total points
ID: 37027430
0
 

Author Comment

by:cdlciddit
ID: 37038730
Thanks. These are very helpful.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37038747
Glad these are :-)
0
 

Author Comment

by:cdlciddit
ID: 37063676
Thanks again for those links they were very helpful. Do you know where I can see the code he used to make AddressBookOld.aspx? That is what I need? There is something there that I am missing. I guess what I'm trying to say is I need my link buttons to do exactly what his select linkbutton did. I want the information to display below when clicked.
0
 

Author Comment

by:cdlciddit
ID: 37063688
I want the details view to show up below the listview with all the information from the database row.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37064573
Are you talking about first link? Is detailview not coming up under the listview?
0
 

Author Comment

by:cdlciddit
ID: 37065451
I fnially got it working. The problem was that I wasn't passing the right CommandName. Thanks for all of your help.
0
 

Author Closing Comment

by:cdlciddit
ID: 37065468
If you follow these examples you will be able to make your listview and detailsview work. But just be sure to pay attention to your CommandName property of your LinkButton.
0

Featured Post

Independent Software Vendors: 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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

616 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