Data Binding a label: Unable to create child list error
I am trying to bind a label to the dataset I have filled through a query. The code to create the data-binding is:
lblDescript.DataBindings.Add("Text",myData,"Image_type.ImageDescription");
Here myData is the dataset I have filled in by executing a query, Image_type is one of the tables the query runs on and ImageDescription is a field in it. However when I run this, I am getting a "Unable to create child list for field or property ImageDescription" error. What am I doing wrong in the code?
vishwanath sPosted Mar 25, 2009, 4:59 AM
Hiii
Do the following steps
// Step1:Create the SqlDataReader object
SqlDataReader SqlDr;
//Step2 :Create the SqlCommand object
SqlCommand
ObjSqlCmd = new SqlCommand();//Step3: Creat the DataTable object
DataTable
Table = new DataTable();//Step4: Create the SqlConnection object
SqlConnection ObjSqlCon = new SqlConnection();
//Step6: Set the ConnectionString property of ObjSqlCon
//Step5:Set the Command Text property of ObjSqlCmd
//Step6:Set the Connection Text Property of objSqlCmd
//Step7:Execute the query
SqlDr = ObjSqlCmd.ExecuteReader();
//Step8 : fill the DataTable
Table.Load(SqlDr);
//Step9:Add the DataTable to the Dataset object
Ds.Tables.Add(Table);
//Step10 : Binding
label1.DataBindings.Add(
"text", Ds.Tables[0], "id");