如果我在cmbGrNo.text
寫話,會有一個下拉組合框的if else語句錯誤
輸入的字符串格式不正確
我怎樣才能識別哪些組合框是編輯? 我寫在組合框,然後單擊搜索按鈕編譯器給我錯誤,因爲它不接受其他組合框文本。它僅接受第一個值... 請幫我
這裏是代碼
private void btnSearch_Click(object sender, EventArgs e)
{
if (cmbAdmissionNo.Text.Length == 0 && cmbRollNo.Text.Length == 0 && cmbStudentName.Text.Length == 0 && cmbGRNo.Text.Length == 0)
{
MessageBox.Show("Enter Student Name OR Admission No OR Gr No OR Roll No"," INSERT FIELDS", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (StudentDBClass.CheckStudent(cmbStudentName.Text))
{
DataTable dt = StudentDBClass.getTableBYStdName(cmbStudentName.Text);
txtAdminNo.Text = "Admission No : " + dt.Rows[0]["AddmissionNo"];
txtGrNo.Text = "GR No : " + dt.Rows[0]["GRNo"];
txtClass.Text = "Class : " + dt.Rows[0]["ClassName"];
txtStudentName.Text = "Student Name : " + dt.Rows[0]["StudentName"];
txtFatherName.Text = "Father Name : " + dt.Rows[0]["FatherName"];
txtRollNo.Text = "Roll No: " + dt.Rows[0]["RollNo"];
dgvStdFeeCollection.DataSource = null;
dgvStdFeeCollection.DataSource = StudentFeeCollectionDBClass.getStdNameForDgvFeeCollection(cmbStudentName.Text);
cmbAdmissionNo.SelectedIndex = -1;
cmbGRNo.SelectedIndex = -1;
cmbRollNo.SelectedIndex = -1;
cmbAdmissionNo.Text = string.Empty;
cmbGRNo.Text = string.Empty;
cmbRollNo.Text = string.Empty;
}
else if (StudentDBClass.CheckWithAdmissionNo(Convert.ToInt32(cmbAdmissionNo.Text)))
{
DataTable dt = StudentDBClass.getTableBYAddmissionNo(Convert.ToInt32(cmbAdmissionNo.Text));
txtAdminNo.Text = "Admission No : " + dt.Rows[0]["AddmissionNo"];
txtGrNo.Text = "GR No : " + dt.Rows[0]["GRNo"];
txtClass.Text = "Class : " + dt.Rows[0]["ClassName"];
txtStudentName.Text = "Student Name : " + dt.Rows[0]["StudentName"];
txtFatherName.Text = "Father Name : " + dt.Rows[0]["FatherName"];
txtRollNo.Text = "Roll No: " + dt.Rows[0]["RollNo"];
dgvStdFeeCollection.DataSource = null;
dgvStdFeeCollection.DataSource = StudentFeeCollectionDBClass.getAdmissionNoForDgvFeeCollection(Convert.ToInt32(cmbAdmissionNo.Text));
cmbStudentName.SelectedIndex = -1;
cmbGRNo.SelectedIndex = -1;
cmbRollNo.SelectedIndex = -1;
cmbGRNo.Text = string.Empty;
cmbStudentName.Text = string.Empty;
cmbRollNo.Text = string.Empty;
}
else if (StudentDBClass.CheckGRNo(Convert.ToInt32(cmbGRNo.Text)))
{
DataTable dt = StudentDBClass.getTableGrNo(Convert.ToInt32(cmbGRNo.Text));
txtAdminNo.Text = "Admission No : " + dt.Rows[0]["AddmissionNo"];
txtGrNo.Text = "GR No : " + dt.Rows[0]["GRNo"];
txtClass.Text = "Class : " + dt.Rows[0]["ClassName"];
txtStudentName.Text = "Student Name : " + dt.Rows[0]["StudentName"];
txtFatherName.Text = "Father Name : " + dt.Rows[0]["FatherName"];
txtRollNo.Text = "Roll No: " + dt.Rows[0]["RollNo"];
dgvStdFeeCollection.DataSource = null;
dgvStdFeeCollection.DataSource = StudentFeeCollectionDBClass.getGrNoForDgvFeeCollection(Convert.ToInt32(cmbGRNo.Text));
cmbAdmissionNo.SelectedIndex = -1;
cmbStudentName.SelectedIndex = -1;
cmbRollNo.SelectedIndex = -1;
cmbAdmissionNo.Text = string.Empty;
cmbStudentName.Text = string.Empty;
cmbRollNo.Text = string.Empty;
}
是與組合框的selected.value或選定的索引。 – jhyap
當您通過此調試時,「cmbGrNo.Text」的值是多少? – paqogomez