110,536
社区成员
发帖
与我相关
我的任务
分享
public partial class _Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
DataSet dsPlant = new DataSet();
SqlDataAdapter sdap = new SqlDataAdapter();
SqlCommand sc = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int i = 0;
if (con.State == ConnectionState.Closed)
con.Open();
try
{
sc.CommandText = "select plname,OrderNo from GS_pl_Plant order by plorderby,orderno";
sc.Connection = con;
sdap.SelectCommand = sc;
sdap.Fill(dsPlant,"plant");
}
finally
{
con.Close();
}
DropDownList1.Items.Clear();
for (i = 0; i <= dsPlant.Tables[0].Rows.Count - 1; i++)
{
DropDownList1.Items.Add(dsPlant.Tables[0].Rows[i][0].ToString());
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
//int si = DropDownList1.SelectedIndex;
Label3.Text = dsPlant.Tables[0].Rows[3][0].ToString(); //此处发生错误
}
}