📄 bind_drpdownlist.cs
字号:
using System;
using System.Data.SqlClient;
using System.Data;
namespace Super_Market
{
/// <summary>
/// bind_DrpDownList 的摘要说明。
/// </summary>
public class bind_DrpDownList
{
public bind_DrpDownList(string sql,System.Web.UI.WebControls.DropDownList DropDownList)
{
//
// TODO: 在此处添加构造函数逻辑
//
SqlConnection Conn;
Conn=new SqlConnection("server=localhost;database=MyTest;uid=sa;pwd=''");
String strSQL = sql;
SqlCommand Comm = new SqlCommand(strSQL,Conn);
SqlDataAdapter da = new SqlDataAdapter();
Conn.Open();
da.SelectCommand = Comm;
DataSet ds = new DataSet();
da.Fill(ds,"grade");
DropDownList.DataSource = ds.Tables["grade"].DefaultView;
DropDownList.DataTextField="TYPE_NAME";
DropDownList.DataBind();
Conn.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -