日期:2014-05-20 浏览次数:20845 次
public void DDL_PersonName() { JSJXXKDBDataContext lqDB = new JSJXXKDBDataContext(ConfigurationManager.ConnectionStrings["JSJXXZX_DBConnectionString"].ConnectionString.ToString()); var result = from per in lqDB.a_employee_mi where per.deleted_flag == '0' select new { name = per.name }; DropDownList1 //在这里,调不出DropDownList1 , }
<asp:TemplateField HeaderText="选吧"> <ItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server" DataSource='<%#DDL_PersonName()%>'> // 不好用 </asp:DropDownList> </ItemTemplate> </asp:TemplateField>
var hospitals = from h in db.B_Hospital where h.IsDel == 1 orderby h.HospitalName select h; ddlHospital.DataSource = hospitals; ddlHospital.DataTextField = "HospitalName"; ddlHospital.DataValueField = "ID"; ddlHospital.DataBind();