D
Doogie
Hi,
I'm sure it's just something I'm not seeing but for some reason, an
event I have set up to be called when a combo box has been switched to
a new value is not being fired for some reason and I can't figure out
why. Below is my HTML.
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="DataCreator.aspx.cs" Inherits="DataCreator" %>
<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<aspropDownList ID="cbSqlServers" runat="server"
OnSelectedIndexChanged="cbSqlServers_SelectedIndexChanged"/>
<aspropDownList ID="cbDatabases" runat="server"
AutoPostBack="True"/>
</div>
</form>
</body>
</html>
and below is my code behind page (there are calls to other cs files,,
that I'm not including here, if needed I can add them).
Mainly I'm trying to figure out why in the GetSqlServers method, when
the index value is changed it doesn't kick off
cbSqlServers_SelectedIndexChanged. And it's not kicked off when I
manually change the index value on the screen.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class DataCreator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GetSqlServers();
}
private void GetSqlServers()
{
string[] servers =
ConfigurationManager.AppSettings["SqlServers"].Split('|');
foreach (string server in servers)
{
cbSqlServers.Items.Add(server);
}
if (cbSqlServers.Items.Count > 0)
{
cbSqlServers.SelectedIndex = 0;
}
}
protected void cbSqlServers_SelectedIndexChanged(object sender,
EventArgs e)
{
cbDatabases.Items.Clear();
cbDatabases.Text = String.Empty;
string sqlServer = cbSqlServers.SelectedItem.ToString();
cbDatabases.DataSource =
DataCreatorController.GetDatabases(sqlServer);
if (cbDatabases.Items.Count > 0)
{
cbDatabases.SelectedIndex = 0;
}
}
}
I'm sure it's just something I'm not seeing but for some reason, an
event I have set up to be called when a combo box has been switched to
a new value is not being fired for some reason and I can't figure out
why. Below is my HTML.
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="DataCreator.aspx.cs" Inherits="DataCreator" %>
<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<aspropDownList ID="cbSqlServers" runat="server"
OnSelectedIndexChanged="cbSqlServers_SelectedIndexChanged"/>
<aspropDownList ID="cbDatabases" runat="server"
AutoPostBack="True"/>
</div>
</form>
</body>
</html>
and below is my code behind page (there are calls to other cs files,,
that I'm not including here, if needed I can add them).
Mainly I'm trying to figure out why in the GetSqlServers method, when
the index value is changed it doesn't kick off
cbSqlServers_SelectedIndexChanged. And it's not kicked off when I
manually change the index value on the screen.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class DataCreator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GetSqlServers();
}
private void GetSqlServers()
{
string[] servers =
ConfigurationManager.AppSettings["SqlServers"].Split('|');
foreach (string server in servers)
{
cbSqlServers.Items.Add(server);
}
if (cbSqlServers.Items.Count > 0)
{
cbSqlServers.SelectedIndex = 0;
}
}
protected void cbSqlServers_SelectedIndexChanged(object sender,
EventArgs e)
{
cbDatabases.Items.Clear();
cbDatabases.Text = String.Empty;
string sqlServer = cbSqlServers.SelectedItem.ToString();
cbDatabases.DataSource =
DataCreatorController.GetDatabases(sqlServer);
if (cbDatabases.Items.Count > 0)
{
cbDatabases.SelectedIndex = 0;
}
}
}