这是我从数据库中检索数据并在树控件中显示的代码
String empid = ValueBox1.Text;
string constr = System.Configuration.ConfigurationManager.ConnectionStrings["EmployeeDatabase"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("ReportingManagers", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@EmpID",SqlDbType.Int,0).Value = empid;
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
//Here "Node" Means It Will Add Nodes As All Root Nodes...
TreeView1.Nodes.Add(dr.GetValue(0).ToString());
}
dr.Close();
我在这一行收到错误:
TreeView1.Nodes.Add(dr.GetValue(0).ToString());
错误:“System.Web.UI.WebControls.TreeNodeCollection.Add(System.Web.UI.WebControls.TreeNode)”的最佳重载方法匹配有一些无效参数。
错误:参数 1:无法从“字符串”转换为“System.Web.UI.WebControls.TreeNode”
请帮我解决这个问题..