(cmbSelect)为自定义的下拉框name;cmbSelect.SelectedIndex表示下拉框内集合的序号,由0开始计起。
例如:
1 int i = cmbSelect.SelectedIndex; 2 switch (i) 3 { 4 case 0: 5 sql1 = "select * from Student where sno='" + texSelect.Text.Trim() + "'"; 6 break; 7 case 1: 8 sql1 = "select * from Student where sname like '%" + texSelect.Text.Trim() + "'"; 9 break; 10 case 2: 11 sql1 = "select * from Student where sex like '%" + texSelect.Text.Trim() + "'"; 12 break;
自己真的是好菜啊,呃啊啊啊啊。。。