I want to display values in a listview within another listview.
I already displayed values in the parent listview(lvPackage) but I don't know to insert values in the child listview.
I'm using mysql. My only problem is that I don't know how to display values lblPackAct in child listview(lvPackAct).
Here's what I've got so far.. Thanks in advance to those who will reply in this post..
<asp:ListView ID="lvPackage" runat="server" EditIndex="1">
<LayoutTemplate>
<table style="width:100%">
<tr>
<td>
<table id="tblPackage" runat="server" border="1" style="width:100%" bordercolor="#006600">
<tr class="size">
<th id="Th11" runat="server">
Reserve</th>
<th id="Th22" runat="server">
Package Name</th>
<th id="Th33" runat="server" align="center">
No. of Persons</th>
<th id="Th55" runat="server" align="center">
Rate</th>
<th id="Th44" runat="server">
Details</th>
<th id="Th88" runat="server" align="center">
Image</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox id="chkReservePack" runat="server"/>
</td>
<td>
<asp:Label ID="lblPackage" runat="server" Font-Bold="True" Font-Size="13px" /><br/>
<asp:ListView ID="lvPackAct" runat="server" EditIndex="1">
<LayoutTemplate>
<table id="tbl" runat="server" border="1" style="width:100%" bordercolor="#006600">
<tr ID="itemPlaceholder3" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr26" runat="server">
<td id="Td26" runat="server">
<asp:Label ID="lblPackAct" runat="server"/> ' I want to display values here.
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</td>
<td align="center">
<asp:Label runat="server" Text = "Enter No. <br/> of Persons:" Font-Bold="True" /><br/>
<asp:Textbox ID="txtPackPersons" width = "60" runat="server" /><br/>
</td>
<td>
<asp:Label ID="lblRate" runat="server" Font-Bold="True"/>
</td>
<td>
<asp:Label ID="lblDetailsPack" runat="server"/>
</td>
<td align="center" bgcolor="#663300">
<asp:Image ID="img2" runat="server" Width = "100" Height = "100" onmouseover="show(this)" onmouseout="hide(this)"/>
</td>
<div id="enlarge_images" style="position: absolute; z-index:2"></div>
</tr>
</ItemTemplate>
</asp:ListView>
'---------------------------------------------------------------------------------------
Imports System.Data.Odbc
Partial Class Reserve22
Inherits System.Web.UI.Page
Dim connStr As String = "Driver={MYSQL ODBC 5.1 Driver};Server=localhost;Database=ecopark_db;UID=root;PWD=1609"
Dim conn As New OdbcConnection(connStr)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack() Then
BindDataPackage()
End If
End Sub
Protected Sub BindDataPackage()
Dim comm As New OdbcCommand
Dim dr As OdbcDataReader
conn.Open()
comm.Connection = conn
comm.CommandText = "SELECT * FROM pack_tbl order by packno"
dr = comm.ExecuteReader
lvPackage.DataSource = dr
lvPackage.DataBind()
comm.Dispose() : dr = Nothing : conn.Close()
End Sub
Protected Sub lvPackage_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles lvPackage.ItemDataBound
Dim lvDataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
Dim lblPackage As Label = CType(e.Item.FindControl("lblPackage"), Label)
If Not IsNothing(lblPackage) Then
lblPackage.Text = lvDataItem.DataItem("PackNo") & ".) " & lvDataItem.DataItem("PackDesc")
End If
Dim lblRate As Label = CType(e.Item.FindControl("lblRate"), Label)
If Not IsNothing(lblRate) Then
lblRate.Text = "Php " & lvDataItem.DataItem("Rate") & " / person"
End If
Dim lblDetailsPack As Label = CType(e.Item.FindControl("lblDetailsPack"), Label)
If Not IsNothing(lblDetailsPack) Then
If InStr(lvDataItem.DataItem("Includes"), "|") Then
Dim arr() As String = lvDataItem.DataItem("Includes").ToString.Split("|")
For i = 0 To arr.Length - 1
lblDetailsPack.Text &= arr(i) & "<br>"
Next
Else
lblDetailsPack.Text = lvDataItem.DataItem("Includes")
End If
End If
Dim img2 As System.Web.UI.WebControls.Image = CType(e.Item.FindControl("img2"), System.Web.UI.WebControls.Image)
If Not IsNothing(img2) Then
img2.ImageUrl = lvDataItem.DataItem("Image")
End If
End Sub
End Class