ado.Net - vb.net customised page using ASPEnterpriseManager.dll

I am writting customised vb.net web-based pages and making use of ASPEnterpriseManager.dll The page references the dll to make the server connection. It lists all sql databse names with the following code.
For X = 0 To Server.Databases.Count - 1
Response.Write(Server.Databases(X))
Next
The question is that I want to list the db names in a repeater by adding the following.
If Items.Count <> 0 Then
Repeater1.DataSource = Server.Databases
Repeater1.DataBind()
It is not listing because I am not sure the following is correct in aspx page.
<%#Container.DataItem.ObjectName%>
The repeater is declared as follows:
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater
I have a copy of the source code for the dll, if needed to be posted to help.
Thanks in advance.
'****************************************************
'app/cmsDataMenu.aspx.vb
'****************************************************
Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Data.SqlClient
Imports System.IO
Imports System.Text
Imports System.Drawing
Imports System.Data.OleDb
Imports Microsoft.VisualBasic
Imports ASPEnterpriseManager
 
Namespace ASPEnterpriseManager.Pages
    
    Public Class cmsDataMenu
        Inherits System.Web.UI.Page
        Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
        Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater
        ' initiate variables etc
        Public Source As DataView
        Public Ds As DataSet
        Sub Page_Load(ByVal Sender As System.Object, ByVal E As System.EventArgs)
            Dim _Context As HttpContext = HttpContext.Current
            If Not Page.IsPostBack Then
                Dim X As Integer
                Dim Y As Integer
                Dim Server As ASPEnterpriseManager.Server = New ASPEnterpriseManager.Server
                Dim Database As ASPEnterpriseManager.Database
                'Dim Roles As ASPEnterpriseManager.ServerRoles = New ASPEnterpriseManager.ServerRoles
                'Roles.Load()
                Server.LoadDatabases()
                'If ConnectionString.InitialCatalog <> "" Then
                Database = New ASPEnterpriseManager.Database
                Database.LoadObjects()
                Session("Database") = Database
                'End If
                Session("Server") = Server
                Dim messageLabel As String = "ConnectionString.InitialCatalog"
                Y = 0
                For X = 0 To Server.Databases.Count - 1
                    Y = Y + 1
                    Response.Write(Server.Databases(X))
                Next
                If Items.Count <> 0 Then
                    Repeater1.DataSource = Server.Databases
                    Repeater1.DataBind()
                End If
            End If
        End Sub
        Private Shared Shadows Sub Init()
            ' initiate variables etc
        End Sub
        Protected Sub testDatabase_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
 
        End Sub
    End Class
    
End Namespace
'****************************************************
'app/cmsDataMenu.aspx
'****************************************************
<%@ Page Language="VB" src="cmsDataMenu.aspx.vb" Inherits="ASPEnterpriseManager.Pages.cmsDataMenu" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Sever Connection</title>
<style type="text/css">
</style>
</head>
<!--
Start Code Section
-->
<body style="background-image: url(images/WebFront.jpg); background-repeat:repeat-x">
<form id ="form1" runat="server">
<% if request("Sync") <> "true" then AppInterface.SyncLeftFrame() 
    'if ConnectionString.InitialCatalog <> "" then %>
<table id="table2" style="z-index:102; position:absolute; top:10px; left:10px; width:auto">
<tr>
<td>
<div style='width:550px; height:550px; overflow:auto; background: #ffffff; border: 1px solid #000000;'>
<h6>Heading:2:</h6>
<asp:Repeater id="Repeater1" runat="server">
      <HeaderTemplate>
          <table width="100%" cellpadding="2" cellspacing="0">
	          	<tr><td class="TableHeader">	          
						<h6>cmsDataMenu</h6>
					</td><td class="TableHeader">
						<h6>Description</h6>
					</td></tr>
      </HeaderTemplate>
      <ItemTemplate>
	          <tr ><td  class="TableGrid">
	          <%#Container.DataItem.ObjectName%>
	          </td><td  class="TableGrid">
	          
	          </td></tr>
      </ItemTemplate>
      <FooterTemplate>
          </table>
      </FooterTemplate>
	</asp:Repeater>
</div>
</td>
</tr>
</table>
<!--
End Code Section
-->
</form>
</body>
</html>

Open in new window

homeshopperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jinalCommented:
It would be nice that first take one Gridview control and bind Server.DataBases to GridView so it list down each column .
Then use that column name in Repeater control
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
homeshopperAuthor Commented:
Would it be possible to give an example using GridView?
I tried the following, but still not displaying database names.
DropDownList works in another page, but as you say,
it would be better to use GridView.
<asp:GridView id="GridView1" runat="server" AutoGenerateColumns="true">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" />
</Columns>
</asp:GridView>

 For X = 0 To Server.Databases.Count - 1
                    Response.Write(Server.Databases(X))
                    Y = Y + 1
                Next
                If Y <> 0 Then
                    GridView1.DataSource = Server.Databases
                    GridView1.DataBind()
                End If
The above gives the following error:
A field or property with the name 'Name' was not found on the selected data source. Line 57:                     GridView1.DataBind()
0
homeshopperAuthor Commented:
I have deleted <asp:BoundField DataField="Name" HeaderText="Name" />
it know works.
Just one more question, now it lists the db names, how can I
select an individual name and redirect to another gridview to display the tables contained in the selected database.
0
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

homeshopperAuthor Commented:
I have the following code to try and display tables etc.
<%@ Page Language="VB" src="cmsData.aspx.vb" Inherits="ASPEnterpriseManager.Pages.cmsData" %>
<%@ Import Namespace="ASPEnterpriseManager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Sever Connection</title>
<style type="text/css">
</style>
</head>
<!--
Start Code Section
-->
<body style="background-image: url(images/WebFront.jpg); background-repeat:repeat-x">
<form id ="form1" runat="server">
<% if request("Sync") <> "true" then AppInterface.SyncLeftFrame()
    'if ConnectionString.InitialCatalog <> "" then %>
<table id="table2" style="z-index:102; position:absolute; top:10px; left:20px; width:auto">
<tr>
<td>
<div style='width:550px; height:140px; overflow:auto; background: #ffffff; border: 1px solid #000000;'>
<h6>Heading:2:</h6>
<% if request("Sync") <> "true" then AppInterface.SyncLeftFrame()
    'if ConnectionString.InitialCatalog <> "" then %>
                        <!--      
                        -->
                        <table>
                        <tr>
                        <td>
                         <img src="images/smallIcon_Database.gif" alt="" />
                         </td>
                         <td>
                         <h6>#<%= ConnectionString.InitialCatalog %>#</h6>
                         </td>
                         <td>
                        <a href="cmsData.aspx">&nbsp;Tables&nbsp;</a>
                        <a href="cmsViews.aspx">&nbsp;Views&nbsp;</a>
                        <a href="cmsStoredProcedures.aspx">&nbsp;Stored&nbsp;Procedures&nbsp;</a>
                        <a href="cmsUsers.aspx">&nbsp;Users&nbsp;</a>
                        <a href="cmsDatabaseRoles.aspx">&nbsp;DbRoles&nbsp;</a>
                        <!--
                        -->            
                <% 'Else%>
                <br />
                &nbsp;&nbsp;&nbsp;&nbsp;
                <% 'End If%>
                </td>
                </tr>
                </table>
</div>
</td>
</tr>
</table>
<table id="table3" style="z-index:103; position:absolute; top:160px; left:250px; width:auto">
<tr>
<td>
<div style='width:530px; height:350px; overflow:auto; background: #ffffff; border: 1px solid #000000;'>
<h6>Heading:3:</h6>
<asp:GridView id="GridView2" runat="server" AutoGenerateColumns="true">
<Columns>

</Columns>
</asp:GridView>
</div>
</td>
</tr>
</table>
<!--
End Code Section
-->
</form>
</body>
</html>
Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Data.SqlClient
Imports System.IO
Imports System.Text
Imports System.Drawing
Imports System.Data.OleDb
Imports ASPEnterpriseManager

Namespace ASPEnterpriseManager.Pages

    Public Class cmsData
        Inherits System.Web.UI.Page
        Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
        Protected WithEvents GridView2 As System.Web.UI.WebControls.GridView
        ' initiate variables etc
        Public Source As DataView
        Public Ds As DataSet
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            ' set tabel & database selectedIndexChange
            testDatabase_SelectedIndexChanged(DropDownList1, Nothing)
            If Not IsPostBack Then
                'Response.Write(":Selected:")
            End If
            Init()
        End Sub
        Private Shared Shadows Sub Init()
            ' initiate variables etc
        End Sub
        Protected Sub testDatabase_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
            GridView2.DataSource = Session("Database").Tables
            GridView2.DataBind()
        End Sub

    End Class

End Namespace      
0
homeshopperAuthor Commented:
Should be as follows:
If Not IsPostBack Then
                'Response.Write(":Selected:")
GridView2.DataSource = Session("Database").Tables
            GridView2.DataBind()
End If
I can display system tables, but I would like to display only the
tables applicable to the selected database
0
homeshopperAuthor Commented:
In the first gridview I have added a select button:
<h6>Heading:2:</h6>
<asp:GridView id="GridView1" runat="server" Font-Size="XX-Small" AutoGenerateColumns="true">
<Columns>
<asp:ButtonField CommandName="Select" Text="Select"  />
</Columns>
</asp:GridView>
I want it to display selected db name in <h6>#<%= ConnectionString.InitialCatalog %>#</h6>
This is in code under heading:3:
I have 3 pages in total displaying in an iFrame for the default.aspx
I suspect that system tables and not selected tables in heading:4;
are displayed because the db name is not displayed in heading:3;
I hope the above is clear enough to understand me.
Thanks in advance.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.