private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (Session["YHM"]==null)
{
Response.Redirect("logo.aspx");
}
if (!IsPostBack)
{
BindGrid();
mySql="select js from t_js";
common.JudgeData myJudgeData=new common.JudgeData();
DropDownList_ADD_JS.DataSource=myJudgeData.showDataView(mySql);
DropDownList_ADD_JS.DataTextField="js";
DropDownList_ADD_JS.DataValueField="js";
DropDownList_ADD_JS.DataBind();
DropDownList_ADD_JS.Items.Add("请选择角色");
DropDownList_ADD_JS.SelectedIndex=DropDownList_ADD_JS.Items.Count-1;
}
}
{
// 在此处放置用户代码以初始化页面
if (Session["YHM"]==null)
{
Response.Redirect("logo.aspx");
}
if (!IsPostBack)
{
BindGrid();
mySql="select js from t_js";
common.JudgeData myJudgeData=new common.JudgeData();
DropDownList_ADD_JS.DataSource=myJudgeData.showDataView(mySql);
DropDownList_ADD_JS.DataTextField="js";
DropDownList_ADD_JS.DataValueField="js";
DropDownList_ADD_JS.DataBind();
DropDownList_ADD_JS.Items.Add("请选择角色");
DropDownList_ADD_JS.SelectedIndex=DropDownList_ADD_JS.Items.Count-1;
}
}
SqlDataAdapter myCommand=new SqlDataAdapter ("select ep_code from abcd",myConnection);
myConnection.Open();
DataSet ds =new DataSet();
myCommand.Fill(ds,"ep_code");
this.DropDownList1.DataSource=ds.Tables["ep_code"].DefaultView;
this.DropDownList1.DataTextField="ep_code";
this.DropDownList1.DataBind();
{MyConn=new SqlConnection(objConn);
MyConn.Open();
if(IsPostBack==false)
{
DataSet ds= new DataSet();
string strwwlb = "select * from wwlb";
SqlDataAdapter MyAdapterwwlb = new SqlDataAdapter(strwwlb,objConn);
MyAdapterwwlb.Fill(ds,"wwlb");
DropDownwwlb.DataSource=ds.Tables["wwlb"].DefaultView; DropDownwwlb.DataBind();
DropDownwwdj.DataBind();
}
}
dropdownlist.datasourse=dataset;
dropdownlist.datatextfield="字段名" //要显示在下拉框中的值
dropdownlist.DataValueField="字段名" //传回的值
这样就可以简单的绑定到数据库了
MyAdapterwwlb.Fill(ds,"wwlb");// “System.Data.SqlClient.SqlCommand”并不包含对
// “Fill”的定义
// 已经using System.Data.SqlClient;
不是sqlcommand
当然有fill的定义\