大家来解决一个问题____________________DropDownList1 的相关....知道的就来吧
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.IO;
namespace WebApplication2
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
SqlConnection myCon;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.DropDownList DropDownList2;
int aa;
private void dis()
{
myCon=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings[ "con "]);
myCon.Open();//打开数据库
////DataGrid1数据绑定
string sql1= "select zhanghao_id as 游戏帐号,zhanghao_mima as 密码 from table_zhanghao ";
System.Data.SqlClient.SqlDataAdapter myDa=new SqlDataAdapter(sql1,myCon);
DataSet ds=new DataSet();
myDa.Fill(ds, "table_zhanghao ");
this.DataGrid1.DataSource=ds.Tables[ "table_zhanghao "];
//this.DataGrid1.CurrentPageIndex=0;
this.DataGrid1.DataBind();
myCon.Close();
}
private void dis1()
{
myCon=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings[ "con "]);
myCon.Open();//打开数据库
string sql1= "select zhanghao_id from table_zhanghao ";
System.Data.SqlClient.SqlCommand mycom=new SqlCommand (sql1,myCon);
System.Data.SqlClient.SqlDataReader mydr=mycom.ExecuteReader();
this.DropDownList1.Items.Clear();
while(mydr.Read())
{
this.DropDownList1.Items.Add(mydr.GetString(0));
}
myCon.Close();
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
//if(!this.IsPostBack)
//{
dis();
dis1();
//}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand);
this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
this.DropDownList1.SelectedIndexChanged +=