드롭 다운 목록에서 값을 선택하는 데 문제가 있습니다. 내가 선택한 값과 관계없이 첫 번째 값만이 항상으로 선택됩니다.드롭 다운에서 값을 선택하는 중 문제가 발생했습니다
protected void Button4_Click(object sender, EventArgs e)
{
SqlConnection con;
String strcon = ConfigurationManager.AppSettings["Constr"].ToString();
try
{
if (!IsPostBack)
{
con = new SqlConnection(strcon);
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select user_name from user_details where role='USER'", con);
DataSet ds = new DataSet();
da.Fill(ds);
DropDownList1.DataTextField = "user_name";
DropDownList1.DataSource = ds.Tables[0].DefaultView;
DropDownList1.DataBind();
}
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
protected void Button6_Click(object sender, EventArgs e)
{
string Name = Session["name"].ToString();
SqlConnection con;
String strcon = ConfigurationManager.AppSettings["Constr"].ToString();
try
{
con = new SqlConnection(strcon);
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select user_name,Arival,late,Day_count from attedance where user_name='" + DropDownList1.SelectedItem.Text + "' ", con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
UpdatePanel 또는 이와 유사한 기능이 실행되고 있습니까? 그렇지 않으면 Page_Load에 항목을 선택해야합니다 – Tchami
테이블에서 값을 가져 오는 데 사용됩니다 – Alivia
덕분에 많이 ....... 그것은 페이지 컨트롤에 잘못 입력했습니다. 버튼 컨트롤에 잘못 넣었습니다. 이제 작동 중입니다. . :) – Alivia