|
![](/images/resource/spacer.gif) |
|
มีโค้ดอยากจะให้แปลหน่อยครับ รบกวนมากกกกกน่ะครับ โค้ดที่ท่านเห็นอยู่ เป็น C# app ซึ่ง |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
โค้ดที่ท่านเห็นอยู่ เป็น C# app ซึ่ง โค้ดที่ผมหาเจอนั้น ผมต้องการอยากให้ c# .net ซึ่งบาง method ของ treeview .net ไม่มี รบกวนมากๆเลยน่ะครับ
![database1 database1](https://www.thaicreate.com/upload/stock/20090723133934.jpg?v=1001)
protected void LoadTreeview()
{
try
{
// Create SqlConnection, SqlDataAdapter, Datatable
SqlConnection con = new SqlConnection(connection);
SqlCommand sqlcommand = new SqlCommand("stDocComDetail", con);
sqlcommand.CommandType = CommandType.StoredProcedure;
sqlcommand.Parameters.AddWithValue("@flag", "receiver");
SqlDataAdapter myAdapter = new SqlDataAdapter(sqlcommand);
DataTable table = new DataTable();
con.Open();
myAdapter.Fill(table);
con.Close();
AddKids(null, "ParentID is null", "DisplayOrder", table);
}
catch
{
}
}
protected void AddKids(string parentid, string filter, string sort, DataTable table)
{
DataRow[] foundRows = table.Select(filter, sort);
if (foundRows.Length == 0) return;
TreeNode[] parentNode = treeView1.Nodes.Find(parentid, true);
if (parentid != null)
if (parentNode.Length == 0) return;
for (int i = 0; i <= foundRows.GetUpperBound(0); i++)
{
string nodetype = foundRows[i]["NodeType"].ToString();
string nodetext = foundRows[i]["NodeText"].ToString();
string nodeid = foundRows[i]["ID"].ToString();
TreeNode node = new TreeNode();
node.Text = nodetext;
node.Name = nodeid;
if (parentid == null) treeView1.Nodes.Add(node);
else parentNode[0].Nodes.Add(node);
if (nodetype.ToLower() == "node") AddKids(nodeid, "ParentID=" + nodeid, sort, table);
}
}
Tag : - - - -
![](/images/adv.jpg?v=1001)
|
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2009-07-23 13:40:04 |
By :
yaisuke |
View :
1601 |
Reply :
1 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
try
{
SqlConnection con = new SqlConnection(connection);
SqlCommand sqlcommand = new SqlCommand("stDocComDetail", con);
sqlcommand.Parameters.AddWithValue("@flag", "receiver_hq");
sqlcommand.CommandType = CommandType.StoredProcedure;
sqlcommand.Connection.Open();
SqlDataAdapter myAdapter = new SqlDataAdapter(sqlcommand);
DataTable table = new DataTable();
myAdapter.Fill(table);
DataRow[] foundRows = table.Select(filter, sort);
DataRow[] foundChild = table.Select(filterchild, sort);
DataRow[] foundleft = table.Select(filterchild, sort);
//add ภาคและสาขา
for (int i = 0; i < foundRows.Length; i++)
{
root[i] = Convert.ToString(foundRows[i][0]);
TreeView1.Nodes.Add(new TreeNode(Convert.ToString(foundRows[i][3])));
for (int j = 0; j < foundChild.Length; j++)
{
if (root[i] == Convert.ToString(foundChild[j][1]))
{
TreeNode treeNode = new TreeNode();
treeNode.Text = Convert.ToString(foundChild[j][3]);
TreeView1.FindNode(Convert.ToString(foundRows[i][3])).ChildNodes.Add(treeNode);
for (int x = 0; x < foundleft.Length; x++)
{
if (Convert.ToString(foundChild[j][0]) == Convert.ToString(foundleft[x][1]))
{
TreeNode treeNode1 = new TreeNode();
treeNode1.Text = Convert.ToString(foundleft[x][3]);
TreeView1.FindNode(Convert.ToString(foundRows[i][3]) + "/" + foundChild[j][3]).ChildNodes.Add(treeNode1);
}
}
}
}
}
sqlcommand.Connection.Close();
}
catch (Exception ex)
{
//lblStatus.Text = ex.Message;
}
ได้ล่ะ ตอบๆๆ กระทู้นี้ใจร้ายจังไม่มีใครตอบ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2009-07-28 14:06:26 |
By :
yaisuke |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 03
|