0
나는 드롭 다운리스트 onselectedIndexChanged 문제
<asp:DropDownList ID="authorList" runat="server"
OnSelectedIndexChanged="authorList_Changed" AutoPostBack="true"
></asp:DropDownList>
그런 다음 코드 숨김에서, 나는
protected void Page_Load(object sender, EventArgs e)
{
var a = (from s in p.Authors
select s.FirstName);
authorList.DataSource = p.Authors;
authorList.DataTextField = "Firstname";
authorList.DataValueField = "FirstName";
authorList.DataBind();
authorList.SelectedIndexChanged += new EventHandler(authorList_Changed);
var q = (from s in p.Authors
where s.FirstName.Contains("m")
select s);
Grid1.DataSource = q;
Grid1.DataBind();
// authorList.DisplayMember = "FirstName";
}
public void authorList_Changed(Object sender, EventArgs e)
{
//Author a = (Author) authorList.SelectedItem;
var a = authorList.SelectedValue;
var v = authorList.SelectedItem;
var q2 = (from s in p.Authors
from w in p.Payrolls
where authorList.SelectedValue == s.FirstName
where s.AuthorID == w.AuthorID
select w);
List<Payroll> d = q2.ToList();
if (d.Count > 0)
{
payroltextbox.Text = d.First().PayrollID.ToString();
//authorList.DataBind();
}
else
payroltextbox.Text = "";
// authorList.DataBind();
}
PublishingCompanyEntities p = new PublishingCompanyEntities();
을의 SelectedIndexChanged 졌지 다음 데이터베이스 제기에 바인딩 및
내 ASP 페이지에 드롭 다운 목록을 배치 그러나 문제는있다 그 때 내 드롭 다운 값을 말한다 1 2 3 4 ....... 1 default ....... 그래서 내가 4 선택하면 여전히 1 포스트 백 반환하고 텍스트 상자 (payroltextbox)의 값을 반환합니다 1 .. 제발 도와주세요 .....