I would like to return my data from one function into another which will populate a drop down list. I was just testing this and am pretty sure that it has to do with the variable being passed into the getData function (see below in red), but I'm not seeing exactly where I'm going wrong. Looking up the error message on the net hasn't helped, either... It's probably something very simple but any help would be appreciated. Thanks.
The error message is as follows: "Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource." I'm using VS 2005, C#.
------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
The error message is as follows: "Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource." I'm using VS 2005, C#.
Code:
protected void Page_Load(object sender, EventArgs e)
{
FillState();
}
public SqlDataAdapter getData([COLOR=red]string strSQL[/color])
{
string cnString = ConfigurationManager.ConnectionStrings["StrConn"].ToString();
SqlConnection conn = new SqlConnection(cnString);
conn.Open();
SqlCommand cmd = new SqlCommand(strSQL, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return da;
}
private void FillState()
{
ddlState.DataSource = getData("EXEC SP_GET_STATE");
ddlState.DataTextField = "st_txt";
ddlState.DataValueField = "st_txt";
ddlState.DataBind();
}
------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill