I have created a helper function to Bind Drop down list in asp.net. See my function:
public void BindDDL(string query, DropDownList DDL)
List<Issuetype> obj = new List<Issuetype>();
Issuetype iss = new Issuetype();
iss.DeptId = 1;
iss.Issue = "SSS";
iss.IssuetypeId = 4;
//BALissue Bl = new BALissue();
//List<Issuetype> objSource = null;
//objSource = Bl.Bind_issuetypes(query);
DDL.DataSource = obj;
DDL.DataValueField = Convert.ToString(obj);
DDL.DataTextField = Convert.ToString(obj);
In this way if i send the query name and Dropdownlist id to the function, drop down should be binded by the List of Issuetype entity, You can see the properties of Issuetype in code.
But however i am not able to Set the DataValueField and DataTextField correctly. Every time it is saying index out of range.