SWAMY YT

SWAMY YT

  • 1k
  • 639
  • 28.5k

Dropdown results in Empty = "Enumeration yielded no results"

Sep 5 2018 1:02 AM
hello, i have been try to retrieve the data from the database, but it results in Empty = "Enumeration yielded no results" any solutions. here is my code,
 
public void DiametrDropDown()
{
// string CS = ConfigurationManager.ConnectionStrings[""].ConnectionString;
// string data = "select PHYSICAL_ID,SUBSTRING(MODEL,6,len(MODEL)) as Model from PHYSICAL_DATA_PSYCHOLMETRICS as P";
SqlCommand cmd = new SqlCommand("select PHYSICAL_ID,SUBSTRING(MODEL,6,len(MODEL)) as Model from PHYSICAL_DATA_PSYCHOLMETRICS as P", conn);
conn.Open();
DDLDiameter.DataSource = cmd.ExecuteReader();// where the result from the query is assigned to the dropdown id
DDLDiameter.DataTextField = "Model";
DDLDiameter.DataValueField = "PHYSICAL_ID";
DDLDiameter.DataBind();
conn.Close();
}
 
<asp:DropDownList ID="DDLDiameter" runat="server" ></asp:DropDownList>
<asp:requiredfieldvalidator id="RqdDiameter1" runat="server" ControlToValidate="DDLDiameter" ErrorMessage="Please Select Diameter" Text="*" ForeColor="Red"></asp:requiredfieldvalidator>
</td>

Answers (2)