I'm trying to populate a generic collection but having problems. I'm trying to populate myBookings, which is supposed to store a List. The methods below should fill myBookings with the correct List but for some reason when I count the result (int c), I'm getting a return of 0. Can anyone see what I'm doing wrong?
// .cs
public partial class _Default : System.Web.UI.Page
{
iClean.Bookings myBookings = new iClean.Bookings();
iClean.Booking myBooking = new iClean.Booking();
iClean.Controller myController = new iClean.Controller();
ListItem li = new ListItem();
protected void Page_Load(object sender, EventArgs e)
{
CurrentFname.Text = Profile.FirstName;
CurrentUname.Text = Profile.UserName;
CurrentLname.Text = Profile.LastName;
myBookings.AllBookings = this.GetBookings();
int c = myBookings.AllBookings.Count();
Name.Text = c.ToString();
Address.Text = myBooking.Address;
Phone.Text = myBooking.Phone;
Date.Text = myBooking.DueDate.ToString();
Comments.Text = myBooking.Comments;
}
public List<iClean.Booking> GetBookings()
{
List<iClean.Booking> bookings = new List<iClean.Booking>();
ArrayList records = this.Select("Bookings", "");
for (int i = 0; i < records.Count; i++)
{
iClean.Booking tempBooking = new iClean.Booking();
Hashtable row = (Hashtable)records[i];
tempBooking.ID = Convert.ToInt32(row["ID"]);
tempBooking.Name = Convert.ToString(row["ClientName"]);
tempBooking.Address = Convert.ToString(row["ClientAddress"]);
tempBooking.Phone = Convert.ToString(row["ClientPhone"]);
tempBooking.DueDate = Convert.ToDateTime(row["Bookingdate"]);
tempBooking.Completed = Convert.ToBoolean(row["Completed"]);
tempBooking.Paid = Convert.ToBoolean(row["Paid"]);
tempBooking.Cancelled = Convert.ToBoolean(row["Cancelled"]);
tempBooking.ReasonCancelled = Convert.ToString(row["ReasonCancelled"]);
tempBooking.ContractorPaid = Convert.ToBoolean(row["ContractorPaid"]);
tempBooking.Comments = Convert.ToString(row["Comments"]);
tempBooking.Windows = Convert.ToBoolean(row["Windows"]);
tempBooking.Gardening = Convert.ToBoolean(row["Gardening"]);
tempBooking.IndoorCleaning = Convert.ToBoolean(row["IndoorCleaning"]);
bookings.Add(tempBooking);
}
return bookings;
}
public ArrayList Select(string table, string conditions)
{
// Create something to hosue the records.
ArrayList records = new ArrayList();
try
{
// Open a connection.
OleDbConnection myConnection = new OleDbConnection(this.getConnectionString());
myConnection.Open();
// Generate the SQL
string sql = "SELECT * FROM " + table;
if (conditions != "") { sql += " WHERE " + conditions; }
// Console.WriteLine("Select SQL: " + sql); // In case we need to debug
// Run the SQL
OleDbCommand myCommand = new OleDbCommand(sql, myConnection);
OleDbDataReader myReader = myCommand.ExecuteReader();
// Go through the rows that were returned ...
while (myReader.Read())
{
// ... create Hashtable to keep the columns in, ...
Hashtable row = new Hashtable();
// ... add the fields ...
for (int i = 0; i < myReader.FieldCount; i++)
{
row.Add(myReader.GetName(i), myReader[i]);
}
// ... and store the row.
records.Add(row);
}
// Make sure to close the connection
myConnection.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return records;
}
public string getConnectionString()
{
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=IQQuotes.accdb;";
return connectionString;
}
}
Just a guess, but try this:
public List<iClean.Booking> GetBookings()
{
List<iClean.Booking> bookings = new List<iClean.Booking>();
ArrayList records = this.Select("Bookings", "");
iClean.Booking tempBooking = new iClean.Booking();
for (int i = 0; i < records.Count; i++)
{
tempBooking = new iClean.Booking();
Hashtable row = (Hashtable)records[i];
tempBooking.ID = Convert.ToInt32(row["ID"]);
tempBooking.Name = Convert.ToString(row["ClientName"]);
tempBooking.Address = Convert.ToString(row["ClientAddress"]);
tempBooking.Phone = Convert.ToString(row["ClientPhone"]);
tempBooking.DueDate = Convert.ToDateTime(row["Bookingdate"]);
tempBooking.Completed = Convert.ToBoolean(row["Completed"]);
tempBooking.Paid = Convert.ToBoolean(row["Paid"]);
tempBooking.Cancelled = Convert.ToBoolean(row["Cancelled"]);
tempBooking.ReasonCancelled = Convert.ToString(row["ReasonCancelled"]);
tempBooking.ContractorPaid = Convert.ToBoolean(row["ContractorPaid"]);
tempBooking.Comments = Convert.ToString(row["Comments"]);
tempBooking.Windows = Convert.ToBoolean(row["Windows"]);
tempBooking.Gardening = Convert.ToBoolean(row["Gardening"]);
tempBooking.IndoorCleaning = Convert.ToBoolean(row["IndoorCleaning"]);
bookings.Add(tempBooking);
}
return bookings;
}
Related
I want to put this into a loop, the code is working fine
but I can't make a loop for it.
When it detects a new data on a table it will automatically add
another item, on my code below it only shows two user controls but I need to generate all of the value in the table.
Here is the code
public partial class Form1 : Form
{
MySqlConnection connection = new MySqlConnection("datasource=localhost;port=3306;database=rmsdb;username=root;password=");
MySqlCommand command;
MySqlDataAdapter da;
public Form1()
{
InitializeComponent();
LRNincrement();
}
int poss = 10;
public void AddItems(string Text, bool Checked)
{
DynaItems item = new DynamicUserControl.DynaItems(Text, Checked);
PanelContainer.Controls.Add(item);
item.Top = poss;
poss = (item.Top + item.Height + 10);
}
private void additembtn_Click(object sender, EventArgs e)
{
LRNincrement();
txt.Text = "";
}
private void LRNincrement()
{
String selectQuery = "SELECT lrnnumber from rmsdb.studentstable";
command = new MySqlCommand(selectQuery, connection);
da = new MySqlDataAdapter(command);
DataTable table = new DataTable();
da.Fill(table);
if (table.Rows.Count > 0)
{
string trylol = table.Rows[0][0].ToString();
AddItems(trylol, true);
}
if (table.Rows.Count > 1)
{
string trylol1 = table.Rows[1][0].ToString();
AddItems(trylol1, true);
}
}
}
Replace the below the code
{
string trylol = table.Rows[0][0].ToString();
AddItems(trylol, true);
}
if (table.Rows.Count > 1)
{
string trylol1 = table.Rows[1][0].ToString();
AddItems(trylol1, true);
}
with
string itemName = string.Empty;
for(int i = 0; i< table.Rows.Count; i++)
{
itemName = table.Rows[i][0].ToString();
AddItems(itemName, true);
}
I am not able to test this code. But hope this help you to find the solution.
when i want to run this code I get an error which throws "IndexOutOfRangeException" on for loop condition. I have tried to use breakpoints and after my DataSet populated clicked on magnifying glass on it. The Visualizer says that it was an empty DataSet. I would appreciate it if someone can help me!
My PageLoad function includes if(!IsPostBack) like this: (freeQuery.aspx.cs)
if (!IsPostBack
{
ViewState["sortColumn"] = " ";
ViewState["sortDirection"] = " ";
string pageURL = HttpContext.Current.Request.RawUrl;
DataSet tables = new DataSet();
string queryString2 = "show tables;";
tables = connectHive(queryString2, pageURL);
List<string> list = new List<string>();
for (int i = 0; i < tables.Tables[0].Rows.Count; i++)
{
list.Add(tables.Tables[0].Rows[i][0].ToString());
}
ListBox1.DataSource = list;
ListBox1.DataBind();
ListBox1.Rows = (ListBox1.Items.Count / 2) + 3;
}
and connectHive function in BasePage.cs below:
protected DataSet connectHive(string query, string pageURL)
{ // Hadoop Hive Connection
var page = HttpContext.Current.CurrentHandler as Page;
OdbcConnection DbConnection = new OdbcConnection("DSN=Hive2");
DbConnection.ConnectionTimeout = 20000000;
try
{
DbConnection.Open();
}
catch (OdbcException exep)
{
ScriptManager.RegisterStartupScript(page, page.GetType(), "alert", "alert('Error in Query!');window.location ='" + pageURL.Replace("/", "") + "';", true);
}
OdbcCommand cmd = DbConnection.CreateCommand();
OdbcDataAdapter adapter = new OdbcDataAdapter(query, DbConnection);
adapter.SelectCommand.CommandTimeout = 20000000;
DataSet data = new DataSet();
data.EnforceConstraints = false;
try
{
adapter.Fill(data);
}
catch (Exception ex)
{
List<string> parameters = new List<string>();
string pageName = findNameByUrl(HttpContext.Current.Request.RawUrl);
parameters.Add("UserID:");
parameters.Add(Session["sicil"].ToString());
parameters.Add("Exception:");
parameters.Add(ex.ToString());
string parameterString = castParameters(parameters);
string exception = "";
string[] sep = new string[] { "\r\n" };
string[] lines = ex.ToString().Split(sep, StringSplitOptions.RemoveEmptyEntries);
int position = lines[0].ToString().LastIndexOf("FAILED:");
if (position > -1)
exception = lines[0].ToString().Substring(position, lines[0].Length - position);
Session["Exception"] = exception.Replace("'", "");
Log(query, "Select Table(BasePage)", pageName, "Failed", parameterString);
}
DbConnection.Close();
return data;
}
I am trying to keep appending a list of values to lookaheadRunInfo.gerrits until I get a new lookaheadRunInfo.ECJobLink in the while loop,I tried to create a variable “ECJoblink_previous” to capture the previous ECJoblink and create a new list only when they are different and keep appending until ECJoblink_previous changes,I tried as below but its not working,what am I missing?
try
{
Console.WriteLine("Connecting to MySQL...");
conn.Open();
string sql = #"some query";
var ECJoblink_previous ="";
MySqlCommand cmd = new MySqlCommand(sql, conn);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
//Console.WriteLine(rdr[0] + " -- " + rdr[1]);
//Console.ReadLine();
lookaheadRunInfo.ECJobLink = rdr.GetString(0);
if (ECJoblink_previous == lookaheadRunInfo.ECJobLink)
{
//Keep appending the list of gerrits until we get a new lookaheadRunInfo.ECJobLink
var gerritList = new List<String>();
lookaheadRunInfo.gerrits = gerritList.Add(rdr.GetString(2));
}
ECJoblink_previous = lookaheadRunInfo.ECJobLink;
lookaheadRunInfo.UserSubmitted = rdr.GetString(2);
lookaheadRunInfo.SubmittedTime = rdr.GetString(3).ToString();
lookaheadRunInfo.RunStatus = "null";
lookaheadRunInfo.ElapsedTime = (DateTime.UtcNow - rdr.GetDateTime(3)).ToString();
lookaheadRunsInfo.Add(lookaheadRunInfo);
}
rdr.Close();
}
var lookaheadRunsInfo = new List<LookaheadRunInfo>();
LookAheadRunInfo lookaheadRunInfo;
var i = 0;
var ecJoblink_previous = string.Empty;
while (rdr.Read())
{
if (rdr.GetString(0) != ecJoblink_previous)
{
ecJoblink_previous = rdr.GetString(0);
if (i > 0)
{
lookaheadRunsInfo.Add(lookaheadRunInfo);
}
// Create a new lookaheadRunInfo
lookaheadRunInfo = new lookaheadRunInfo
{
ECJobLink = rdr.GetString(0),
UserSubmitted = rdr.GetString(2),
SubmittedTime = rdr.GetString(3).ToString(),
RunStatus = "null",
ElapsedTime = (DateTime.UtcNow - rdr.GetDateTime(3)).ToString(),
gerrits = new List<string>
{
rdr.GetString(2)
}
};
}
else
{
//Keep appending the list of gerrits until we get a new lookaheadRunInfo.ECJobLink
lookaheadRunInfo.gerrits.Add(rdr.GetString(2));
}
}
I have a List (listOfQuestionIDs) stored in ViewState of 10 different numbers and an int counter (questionCounter) stored in ViewState which I intend to use to access the different numbers in the first list.
However, as I increment the value of ViewState["questionCounter"] by 1 the contents of listOfAnswerIDs and listOfAnswers remain exactly the same in the code below. Why is this?
protected void getAnswers()
{
string connStr = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
MySqlConnection conn = new MySqlConnection(connStr);
MySqlDataReader reader;
List<int> listOfQuestionIDs = (List<int>)(ViewState["listOfQuestionIDs"]);
int questionCounter = Convert.ToInt32(ViewState["questionCounter"]);
List<string> listOfAnswerIDs = new List<string>();
List<string> listOfAnswers = new List<string>();
List<string> listOfCorrectAnswerIDs = new List<string>();
try
{
conn.Open();
string cmdText = "SELECT * FROM answers WHERE question_id=#QuestionID";
MySqlCommand cmd = new MySqlCommand(cmdText, conn);
cmd.Parameters.Add("#QuestionID", MySqlDbType.Int32);
cmd.Parameters["#QuestionID"].Value = Convert.ToInt32(listOfQuestionIDs[questionCounter]);
reader = cmd.ExecuteReader();
while (reader.Read())
{
listOfAnswerIDs.Add(reader["answer_id"].ToString());
listOfAnswers.Add(reader["answer"].ToString());
if (reader["correct"].ToString().Equals("Y"))
{
listOfCorrectAnswerIDs.Add(reader["answer_id"].ToString());
}
}
for (int i = 0; i < listOfAnswerIDs.Count; i++)
{
lblTitle.Text += listOfAnswerIDs[i].ToString();
}
reader.Close();
populateAnswers(listOfAnswerIDs.Count, listOfAnswers, listOfAnswerIDs);
}
catch
{
lblError.Text = "Database connection error - failed to read records.";
}
finally
{
conn.Close();
}
ViewState["listOfQuestionIDs"] = listOfQuestionIDs;
ViewState["listOfCorrectAnswerIDs"] = listOfCorrectAnswerIDs;
}
Here's where I increment the questionCounter:
protected void btnNext_Click(object sender, EventArgs e)
{
.........
getNextQuestion();
}
protected void getNextQuestion()
{
int questionCounter = Convert.ToInt32(ViewState["QuestionCounter"]);
..........
getAnswers();
................
questionCounter += 1;
ViewState["QuestionCounter"] = questionCounter;
}
ViewState keys are case sensitive. In getAnswers() you use "questionCounter" and in getNextQuestion() you use "QuestionCounter". Pick one and keep it consistent.
I have problem with button click event and post back. I have a page with some textboxes and some drop-down lists. I fill those textboxes and ddls from database. I also have 2 buttons. One of them is updating database with changed data from textboxes and drop-down lists. Second button is displaying additional data depending on value from one of the drop-down list. My problem is that when I click update button the database is updated and data in textboxes and ddls are changed but when I enter into address tab and push Enter I got old data (In database everything is changed into new values). I could add method to
if (IsPostBack)
and data will be always fresh but in that case I will not be able to change value in one of the drop down list which displays additional data (Auto post back will load data into this ddl). Is there any workaround to this? If my description is not clear, please let me know.
EDIT1 Adding C# code
public partial class EditStaff : System.Web.UI.Page
{
Methods methods = new Methods();
IPrincipal p = HttpContext.Current.User;
protected void Page_Load(object sender, EventArgs e)
{
string soeid = Convert.ToString(Request["soeid"]);
DataSet dsUserDetails = new DataSet();
DataTable dtUserDetails = new DataTable();
DataSet dsDDLs = new DataSet();
if (!IsPostBack)
{
GetDDLsItems();
FillFields();
}
else
{
//FillFields();
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
string update_error = "";
string SOEID = txtSOEID.Text;
string firstName = txtFirstName.Text;
string lastName = txtLastName.Text;
string email = txtEmail.Text.Trim();
int remsCode = Convert.ToInt32(ddlREMS.SelectedItem.ToString());
int active = Convert.ToInt32(ddlActive.SelectedValue);
int isGVO = Convert.ToInt32(ddlIsGVO.SelectedValue);
int gvoTeamID = Convert.ToInt32(ddlGVOTeams.SelectedValue);
int profileID = Convert.ToInt32(ddlProfiles.SelectedValue);
int isSOW = Convert.ToInt16(ddlIsSOW.SelectedValue);
int headcount = Convert.ToInt32(ddlHeadcount.SelectedValue);
string updater_domain = p.Identity.Name.ToString();
string updater = "";
int index = updater_domain.IndexOf("\\");
int email_at_index = email.IndexOf("#");
if (index != -1)
{
updater = updater_domain.Substring(index + 1, 7);
}
else
{
updater = updater_domain;
}
if (firstName.Length < 2)
{
update_error = "First Name should have at least 2 characters. ";
lblStatus.Text = update_error;
lblStatus.ForeColor = System.Drawing.Color.Red;
lblStatus.Visible = true;
}
else if (lastName.Length < 2)
{
update_error = update_error + "Last Name should have at least 2 characters. ";
lblStatus.Text = update_error;
lblStatus.ForeColor = System.Drawing.Color.Red;
lblStatus.Visible = true;
}
else if (email_at_index == -1 && email.Length < 5)
{
update_error = update_error + "Invalid email address.";
lblStatus.Text = update_error;
lblStatus.ForeColor = System.Drawing.Color.Red;
lblStatus.Visible = true;
}
else
{
// create ConnectDatabase object to get acces to its methods
ConnectDatabase connectDB = new ConnectDatabase();
IDBManager dbManager = connectDB.ConnectDB();
DataSet ds = new DataSet();
try
{
dbManager.Open();
dbManager.CreateParameters(13);
dbManager.AddParameters(0, "#SOEID", SOEID);
dbManager.AddParameters(1, "#firstName", firstName);
dbManager.AddParameters(2, "#LastName", lastName);
dbManager.AddParameters(3, "#Email", email);
dbManager.AddParameters(4, "#REMSCode", remsCode);
dbManager.AddParameters(5, "#Active", active);
dbManager.AddParameters(6, "#IsGVO", isGVO);
dbManager.AddParameters(7, "#gvoTeamID", gvoTeamID);
dbManager.AddParameters(8, "#profileID", profileID);
dbManager.AddParameters(9, "#isSOW", isSOW);
dbManager.AddParameters(10, "#headcount", headcount);
dbManager.AddParameters(11, "#lastUpdatedBy", updater);
dbManager.AddParameters(12, "#status", active);
dbManager.ExecuteNonQuery(CommandType.StoredProcedure, "sp_update_user");
}
catch (Exception error)
{
HttpContext.Current.Response.Write(error.ToString());
}
finally
{
dbManager.Close();
dbManager.Dispose();
lblStatus.Visible = true;
lblStatus.Text = "User data updated successfully.";
lblStatus.ForeColor = System.Drawing.Color.Green;
FillFields();
}
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
FillFields();
gvREMSDetails.Visible = false;
}
private void FillFields()
{
string soeid = Convert.ToString(Request["soeid"]);
DataSet dsUserDetails = new DataSet();
DataTable dtUserDetails = new DataTable();
DataSet dsDDLs = new DataSet();
dsUserDetails = GetUserDetails(soeid);
dtUserDetails = dsUserDetails.Tables[0];
string gvoTeam = dtUserDetails.Rows[0].ItemArray[8].ToString();
string profile = dtUserDetails.Rows[0].ItemArray[10].ToString();
string remsCode = dtUserDetails.Rows[0].ItemArray[4].ToString();
txtSOEID.Text = dtUserDetails.Rows[0].ItemArray[0].ToString();
txtFirstName.Text = dtUserDetails.Rows[0].ItemArray[1].ToString();
txtLastName.Text = dtUserDetails.Rows[0].ItemArray[2].ToString();
txtEmail.Text = dtUserDetails.Rows[0].ItemArray[3].ToString();
ddlREMS.SelectedValue = remsCode.ToString();
txtAddress.Text = dtUserDetails.Rows[0].ItemArray[5].ToString();
//Response.Write((Convert.ToInt16(dtUserDetails.Rows[0].ItemArray[6])).ToString());
ddlActive.SelectedValue = (Convert.ToInt16(dtUserDetails.Rows[0].ItemArray[6])).ToString();
ddlIsGVO.SelectedValue = (Convert.ToInt16(dtUserDetails.Rows[0].ItemArray[7])).ToString();
ddlGVOTeams.SelectedValue = gvoTeam;
ddlProfiles.SelectedValue = profile;
ddlIsSOW.SelectedValue = (Convert.ToInt16(dtUserDetails.Rows[0].ItemArray[12])).ToString();
lblLastUpdatedBy_value.Text = dtUserDetails.Rows[0].ItemArray[14].ToString();
lblLastUpdatedDate_value.Text = dtUserDetails.Rows[0].ItemArray[15].ToString();
}
protected void btnGetREMSdetails_Click(object sender, EventArgs e)
{
//int remsCode = Convert.ToInt32(ddlREMS.SelectedValue);
// create ConnectDatabase object to get acces to its methods
ConnectDatabase connectDB = new ConnectDatabase();
IDBManager dbManager = connectDB.ConnectDB();
DataSet ds = new DataSet();
try
{
dbManager.Open();
dbManager.CreateParameters(1);
dbManager.AddParameters(0, "#remscode", Convert.ToInt32(ddlREMS.SelectedValue));
ds = dbManager.ExecuteDataSet(CommandType.Text, "select * from vwREMSDetails where [rems code] = #remscode");
gvREMSDetails.DataSource = ds;
gvREMSDetails.DataBind();
gvREMSDetails.Visible = true;
}
catch (Exception error)
{
HttpContext.Current.Response.Write(error.ToString());
}
finally
{
dbManager.Close();
dbManager.Dispose();
}
}
private static DataSet GetUserDetails(string soeid)
{
// create ConnectDatabase object to get acces to its methods
ConnectDatabase connectDB = new ConnectDatabase();
IDBManager dbManager = connectDB.ConnectDB();
DataSet ds = new DataSet();
try
{
dbManager.Open();
dbManager.CreateParameters(1);
dbManager.AddParameters(0, "#soeid", soeid);
ds = dbManager.ExecuteDataSet(CommandType.Text, "select * from vwUsersDetails where soeid = #soeid");
}
catch (Exception error)
{
HttpContext.Current.Response.Write(error.ToString());
}
finally
{
dbManager.Close();
dbManager.Dispose();
}
return ds;
}
private void GetDDLsItems()
{
// create ConnectDatabase object to get acces to its methods
ConnectDatabase connectDB = new ConnectDatabase();
IDBManager dbManager = connectDB.ConnectDB();
DataSet ds = new DataSet();
try
{
dbManager.Open();
ds = dbManager.ExecuteDataSet(CommandType.StoredProcedure, "sp_select_edit_user_ddls");
ddlREMS.DataSource = ds.Tables[0];
ddlREMS.DataTextField = "remsCode";
ddlREMS.DataValueField = "remsCode";
ddlREMS.DataBind();
ddlActive.DataSource = ds.Tables[1];
ddlActive.DataTextField = "Active";
ddlActive.DataValueField = "ActiveID";
ddlActive.DataBind();
ddlIsGVO.DataSource = ds.Tables[2];
ddlIsGVO.DataTextField = "IsGVO";
ddlIsGVO.DataValueField = "IsGVOID";
ddlIsGVO.DataBind();
//methods.GetGVOFunctions(ddlGVOFunctions);
//int? gvoFunctionID = string.IsNullOrEmpty(ddlGVOFunctions.SelectedValue) ? (int?)null : (int?)Convert.ToInt32(ddlGVOFunctions.SelectedValue);
methods.GetGVOTeams(null, ddlGVOTeams);
ddlProfiles.DataSource = ds.Tables[3];
ddlProfiles.DataTextField = "profilename";
ddlProfiles.DataValueField = "profileID";
ddlProfiles.DataBind();
ddlIsSOW.DataSource = ds.Tables[4];
ddlIsSOW.DataTextField = "IsSOW";
ddlIsSOW.DataValueField = "IsSOWID";
ddlIsSOW.DataBind();
ddlHeadcount.DataSource = ds.Tables[5];
ddlHeadcount.DataTextField = "Headcount";
ddlHeadcount.DataValueField = "HeadcountID";
ddlHeadcount.DataBind();
}
catch (Exception error)
{
HttpContext.Current.Response.Write(error.ToString());
}
finally
{
dbManager.Close();
dbManager.Dispose();
}
}
}
I'm not 100% I completly understand the issue, but it sounds to me that you need to have
if(!IsPostBack)
{
// load dropdown data here
}
where you load all your data into the dropdowns, and then on the dropdown have
<asp:DropDownList SelectedIndexChanged="ddlDropdown_SelectedIndexChanged" id="ddlDropdown" AutoPostBack="true"></asp:DropDownList>
Then in your code behind have
protected void ddlDropDown_SelectedIndexChanged(object sender, EventArgs e)
{
}