dynamic checkboxes
I am new to C#.
I have about 55 checkboxes on a form to choose vaious different options, the labels and labels are dependant on 'frmSchemas.schema' from a previous form.
Is there any way I can get the values from the database to populate on the comboxes dynamically so I dont have to code to read 189 times?
I am sorry if I didnt ask the correct question. I am using the code below but stuck after the dr.Read(); Can anyone help me...
string oradb = "Data Source=";
oradb = oradb + Login.db + ";";
oradb = oradb + "User Id=" + Login.user;
oradb = oradb + ";Password=" + Login.pass + ";";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
sql = "SELECT GCOS_SCHEMA, PROGRAM_FIELD, DBFIELD,PROGRAM_LABEL FROM GENDBA.SUPTALLYACTIVITIESCONFIG where active ='Y开发者_StackOverflow中文版' and GCOS_SCHEMA ='" + frmSchemas.schema + "'";
OracleCommand cmd = new OracleCommand(sql, conn);
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
change dr.Read(); to
while(dr.Read())
{
// loop through the table
}
if your problem is 55 checkboxes, thus 55 diff names to work/code with, switch to CheckBoxList for asp.net or CheckedListBox for winforms.
精彩评论