Hi Basicly I have 2 table in my mapXtreme workspace. One has the cityName and plate number of the city. And the other one has district names and plate number of the city. In my web page, I have 2 drop down lists and 1 button.
I can display city names in 1st dropdown list. What i'm trying is to display districts of the choosen city after i choose city from 1st list and clicked on the button. How can i achieve this?
Here is updated version of the code and error message on browser when i try to run it
:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
/*******************************************/
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MapInfo.Data;
using MapInfo.WebControls;
using ApplicationStateManager;
public partial class myWebForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (StateManager.IsManualState())
{
// If the StateManager doesn't exist in the session put it else get it.
if (StateManager.GetStateManagerFromSession() == null)
{
//instanciate AppStateManager class
AppStateManager myStateManager = new AppStateManager();
//put state manager to session
StateManager.PutStateManagerInSession(myStateManager);
//put current map alias to state manager dictionary
myStateManager.ParamsDictionary[StateManager.ActiveMapAliasKey] = this.MapControl1.MapAlias;
}
// Now Restore State
StateManager.GetStateManagerFromSession().RestoreState();
}
string myQuery = "SELECT cityName FROM CITIES";
MIConnection myConnection = new MIConnection();
MICommand myCommand = new MICommand(myQuery,myConnection);
myConnection.Open();
MIDataReader myReader = myCommand.ExecuteReader();
DropDownList1.Items.Clear();
while (myReader.Read()) {
DropDownList1.Items.Add(new ListItem(
myReader["cityName"].ToString()));
}
myConnection.Close();
myReader.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = DropDownList1.Text;
string cityPlateNumber = "SELECT plateNo from CITIES where cityName = \' " + DropDownList1.Text + " \'";
string cityNo;
MIConnection connect_cityPlateNumber = new MIConnection();
MICommand command_cityPlateNumber = new MICommand(cityPlateNumber, connect_cityPlateNumber);
connect_cityPlateNumber.Open();
MIDataReader reader_cityPlateNumber = command_cityPlateNumber.ExecuteReader();
cityNo = reader_cityPlateNumber["plateNo"].ToString();
string myQuery2 = "SELECT IlceAdi from ILCELER WHERE plateNo = \' " + cityNo + " \'";
connect_cityPlateNumber.Close();
reader_cityPlateNumber.Close();
MIConnection connectIlce = new MIConnection();
MICommand commandIlce = new MICommand(myQuery2, connectIlce);
connectIlce.Open();
MIDataReader readerIlce = commandIlce.ExecuteReader();
DropDownList2.Items.Clear();
while (readerIlce.Read())
{
DropDownList2.Items.Add(new ListItem(
readerIlce["IlceAdi"].ToString()));
}
connectIlce.Close();
readerIlce.Close();
}
// At the time of unloading the page, save the state
private void Page_UnLoad(object sender, System.EventArgs e)
{
if (StateManager.IsManualState())
{
StateManager.GetStateManagerFromSession().SaveState();
}
}
protected void Button2_Click(object sender, EventArgs e)
{
}
}