标签:返回 GridView from use source color rom abi line
首先需要把DropDownList改成允许服务器返回。
然后绑定的时候需要以下两项。
DropDownList1.DataTextField = "name";
DropDownList1.DataValueField = "name";
完整例子
using System.Data;
using System.Data.OracleClient;
string str = "Data Source=127.0.0.1/xkp;User ID=jsb;PassWord=jsb";
string sql = "select name from userlist";
OracleConnection conn = new OracleConnection(str);
OracleDataAdapter dr = new OracleDataAdapter(sql, conn);
DataSet ds = new DataSet();//创建数据集;
dr.Fill(ds); //填充数据集
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "name";
DropDownList1.DataValueField = "name";
DropDownList1.DataBind();
if (conn.State == ConnectionState.Open) //判断数据库连接状态,是否连接
{
conn.Close();
}
DropDownList按照Gridview获取数据获取到的是定义格式
标签:返回 GridView from use source color rom abi line
原文地址:https://www.cnblogs.com/yangsongyan/p/9029167.html