DropDownlistをバインドできません。Sqldatareaderのコードがあります。 出力がありません。私はデータベースからの値を表示し、それをバインドします。ドロップダウンリストをバインドできません
try
{
SqlDataReader ds = obj.GetDataReader("Select Name, Emp_ID from
EMP_Info where Emp_ID in ( select Emp_ID from EMP_Info where Name ='" +
Session["AG_name"].ToString() + "' except select Emp_ID from RosterWeekly
where WeekStartDate between '" + txtDate.Text + "' and '" +
Convert.ToDateTime(txtDate.Text).AddDays(7).ToShortDateString() + "') Order
By Name");
txempid.DataSource = ds;
txempid.DataValueField = "Emp_ID";
txempid.DataTextField = "Name";
txempid.DataBind();
txempid.Items.Insert(0, new ListItem("--Select Employee Name--",
"0"));
txempid.Items.Insert(1, new ListItem(ds[0].ToString(), "1"));
}
catch (Exception ex)
{
}
// dropdownlist code
<asp:DropDownList Height="35" Width="200" ID="txempid" runat="server"
AutoPostBack="true" OnSelectedIndexChanged ="txempid_SelectedIndexChanged" >
</asp:DropDownList>
なぜあなたはデータバインドをしたら項目を挿入していますか? –
あなたのページにこのコードを書き込んだのはどのイベントですか? –
私は単純に挿入していない、私はこのドロップダウンリストをバインドしたい.. –