数据库连接
OracleConnection conn = new OracleConnection("Data Source=duke;Persist Security Info=True;User ID=gxjd;Password=gxjd;");
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
String sqlstr = "select class,unitid from unit ";
cmd.CommandText = sqlstr;
OracleDataAdapter sqlda =new OracleDataAdapter(cmd);//'建立临时表存储省份数据
DataTable Province = new DataTable();
sqlda.Fill(Province);
Response.Write("将class数据绑定到DropDownList1控件");//~~~~~~~~~~~~~就是这里,需要把class绑定输出//
Response.End(); //'将省份数据绑定到DropDownList1控件
DropDownList1.DataSource = Province;
DropDownList1.DataValueField = "unitid";
DropDownList1.DataTextField = "class";
DropDownList1.DataBind();////////
Response.Write("将class数据绑定到DropDownList1控件");这里不知道里面该怎么写..
OracleConnection conn = new OracleConnection("Data Source=duke;Persist Security Info=True;User ID=gxjd;Password=gxjd;");
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
String sqlstr = "select class,unitid from unit ";
cmd.CommandText = sqlstr;
OracleDataAdapter sqlda =new OracleDataAdapter(cmd);//'建立临时表存储省份数据
DataTable Province = new DataTable();
sqlda.Fill(Province);
Response.Write("将class数据绑定到DropDownList1控件");//~~~~~~~~~~~~~就是这里,需要把class绑定输出//
Response.End(); //'将省份数据绑定到DropDownList1控件
DropDownList1.DataSource = Province;
DropDownList1.DataValueField = "unitid";
DropDownList1.DataTextField = "class";
DropDownList1.DataBind();////////
Response.Write("将class数据绑定到DropDownList1控件");这里不知道里面该怎么写..
1 设置数据源 DataSource
2 设置要显示的列 DataSelectText
3 设置作为Value的列 DataSelectValue
4 调用DataBind()方法,呈现在页面上
(现在都是代码自动感知,也不知道属性写得又没有错)