Using ObjectDataSource to populate a DropDownField
I am attempting to use an ObjectDataSource to populate a DropDownList. I am passing parameters to the following method in order to determine what should be in the drop down. I have determined that when a dataset is being referenced, the following error comes up:
Error: There was an error rendering the control. Exception has been thrown by the target of an invocation.
Code:
public static DataView TstGetPhaseListForProjects(int projectId, int tableOrigin)
{
DataTable dt = new DataTable("PhaseList");
dt.Columns.Add("code");
dt.Columns.Add("name");
string phaseNumber;
DataSet dsData = new DataSet();
//SqlHelper.ExecuteDataset(System.Configuration.ConfigurationManager.AppSettings[ODSComponentsLibrary.GlobalVars.CfgKeyConnStringODSNOP], SP_SELECT,
// tableOrigin, 0, projectId, "All");
foreach (DataRow row in dsData.Tables[0].Rows)
{
phaseNumber = row["phase_no"].ToString();
dt.Rows.Add(phaseNumber, phaseNumber);
}
return (dt.DefaultView);
}
The above error shows up on the GridView rendering and the Gridview does not draw properly.
Thanks in advance for your help.