Hello Team,
I have created a Property such as
public string ApplicationLevelMode;
public string SchoolMode
{
set {ApplicationLevelMode = value;}
get {return ApplicationLevelMode;}
}
Now i have a combo box and assigning the selected value of the combo box to the above proprty
private void BindDropdown()
{
DataTable dtSchool = new DataTable();
dtSchool.Columns.Add("Text", typeof(string));
dtSchool.Columns.Add("Value", typeof(string));
dtSchool.Rows.Add("---------Select---------", "0");
dtSchool.Rows.Add("Presentation Convent School", "8");
dtSchool.Rows.Add("Aparna Educational Trust", "9");
cmbSchool.DataSource = dtSchool;
cmbSchool.DisplayMember = "Text";
cmbSchool.ValueMember = "Value";
cmbSchool.SelectedIndex = 0;
}
private void SchoolSelection_Load(object sender, EventArgs e)
{
BindDropdown();
}
private void btnSubmit_Click(object sender, EventArgs e)
{
if (cmbSchool.SelectedIndex > 0)
{
this.ApplicationLevelMode = cmbSchool.SelectedValue.ToString();
MDI objMDI = new MDI();
this.Hide();
objMDI.Show();
}
else
{
MessageBox.Show("Please select school first!");
}
}
Now on Second Form i want to use this variable and pass it as a Parameter to the function.
I am doing it as creating an object of the form globally and trying to access the value directly on the function on a button click event this.ApplicationLevelMode = cmbSchool.SelectedValue.ToString(); this is in different form
frmss objss = new frmss()
code of button click where i am trying to get the value
private void SaveClass(string mode)
{
IList<string> lstvalues = new List<string>();
try
{
lstvalues.Add(mode);
lstvalues.Add(Convert.ToString(xClassID));
lstvalues.Add(xtxtClass.Text.Trim());
lstvalues.Add("1");
objmaster.InsertClass(lstvalues,
objSS.ApplicationLevelMode) ; // this value is coming null.I want to get the value that is assigned in
MessageBox.Show("Data Saved");
Clear();
}
catch (Exception ex)
{
errdesc = ex.Message;
MessageBox.Show(errdesc);
xtxtClass.Focus();
}
Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved