HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<title></title>
</head>
<body>
<form id="form1" runat = "server">
Server: <asp:TextBox ID = "txtInstance" runat = "server" /><br />
UserName: <asp:TextBox ID = "txtUserName" runat = "server" /><br />
Password: <asp:TextBox ID = "txtPassword" runat = "server" TextMode = "Password" /><br />
<asp:Button ID = "btnConnect" OnClick = "Connect" Text = "Connect" runat = "server" /><br />
Databases:<asp:DropDownList ID = "ddlDatabases" runat = "server"></asp:DropDownList>
</form>
</body>
</html>
Code
protected void Connect(object sender, EventArgs e)
{
String connString = string.Format("Data Source={0};User ID={1};Password={2}", txtInstance.Text, txtUserName.Text, txtPassword.Text);
using (SqlConnection con = new SqlConnection(connString))
{
con.Open();
DataTable dtDatabases = con.GetSchema("Databases");
con.Close();
ddlDatabases.DataSource = dtDatabases;
ddlDatabases.DataTextField = "database_name";
ddlDatabases.DataValueField = "dbid";
ddlDatabases.DataBind();
}
}