ورود

View Full Version : سوال: مشكل با treeview



s_mokhtari
یک شنبه 24 مرداد 1389, 10:13 صبح
با سلام
دوستان با سرچي كه توي سايت كردم يه برنامه پيدا كردم ولي اون براي يه جدول من ميخوام گروه كالا به همراه زيرگروهاش نشون بده كه از دو جدول وقتي تريس ميكنم تمام اطلاعات رو درست نشون ميده ولي توي تري‌ويو هيچي نشون نميده اينم كدش
دوستان راهنماييم كنيد
مممممممنون:خجالت::خجالت:
من كد شما رو اينطوري نوشتم وقتي تريس كنيد تمام گروهها و زير گروهها رو نشون ميده ولي توي تري‌ويو چيزي ندارم

SqlConnection _cn1 = new SqlConnection(ConfigurationSettings.AppSettings["connectionstring"]);
SqlConnection _cn2 = new SqlConnection(ConfigurationSettings.AppSettings["connectionstring"]);

if (_cn1.State != ConnectionState.Open) _cn1.Open();
if (_cn2.State != ConnectionState.Open) _cn2.Open();

SqlCommand _cmd1 = new SqlCommand("SELECT ID,CategoryName FROM Category", _cn1);
SqlDataReader _dr1 = _cmd1.ExecuteReader();

while (_dr1.Read())
{
TreeNode node = new TreeNode();

node.Text = _dr1["CategoryName"].ToString();
node.Value = _dr1["ID"].ToString();

node.PopulateOnDemand = true;
node.SelectAction = TreeNodeSelectAction.Expand;


// // parent.ChildNodes.Add(node);

// //--------------------------------------------
SqlCommand _cmd2 = new SqlCommand("SELECT IDm,id,matername FROM Tbl_Mater where id=@id", _cn2);
_cmd2.Parameters.AddWithValue("@id", _dr1["id"]);
SqlDataReader _dr2 = _cmd2.ExecuteReader();
while (_dr2.Read())
{
TreeNode node2 = new TreeNode();

node2.Text = _dr2["matername"].ToString();
node2.Value = _dr2["idm"].ToString();
node2.NavigateUrl = "ProductDesc.aspx?idm=" + node2.Value;
node2.Target = "_blank";
node2.PopulateOnDemand = true;
node2.SelectAction = TreeNodeSelectAction.Select;

// parent2.ChildNodes.Add(node2);
}
_dr2.Close();


}
_cn2.Close();


}
مممممنون