hi ...
Here we have a datalist and in that datalist another datalist for each row...
so it will create output like shown in image at right side..
here is code for that
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:DataList ID="DataList1" runat="server" DataKeyField="CenterCode" Style="z-index: 22; left: 56px; position: absolute; top: 88px"> <ItemTemplate> <ul> <li> <asp:Label ID="CenterNameLabel" runat="server" Text='<%# Eval("CenterName") %>'> </asp:Label> <asp:DataList ID="DataList2" runat="server"> <ItemTemplate> <ul> <li> <asp:Label ID="DepartmentNameLabel" runat="server" Text='<%# Eval("DepartmentName") %>'> </asp:Label></li> </ul> </ItemTemplate> </asp:DataList> </li> </ul> </ItemTemplate> </asp:DataList> </div> </form> </body> </html>
now in default.aspx.vb file write this code
Imports System.Data Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ds As DataSet Dim obj As New ClsMain ds = obj.connect("select * from TblCenter") DataList1.DataSource = ds DataList1.DataBind() End Sub Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound Dim PriceLabel As Label = CType(e.Item.FindControl("CenterNameLabel"), Label) Dim dl As DataList dl = CType(e.Item.FindControl("DataList2"), DataList) Dim ds As DataSet Dim obj As New ClsMain Dim i As String = DataList1.DataKeys.Item(0) ds = obj.connect("SELECT TblDepartment.DepartmentName FROM TblCenter INNER JOIN TblDepartment ON TblCenter.CenterCode = TblDepartment.CenterCode WHERE (TblCenter.CenterName = '" & PriceLabel.Text & "')") dl.DataSource = ds dl.DataBind() End Sub End Class
All The Best....
No comments:
Post a Comment