/////代码
private void Button3_Click(object sender, System.EventArgs e)
{
string selectID=pclassTree.SelectedNodeIndex;
string pcID=pclassTree.GetNodeFromIndex(selectID).NodeData;
Response.Write(pcID);
// int pcID=Convert.ToInt32(pid);
SqlConnection con=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["SQLCONSTR"]);
SqlCommand cmd=new SqlCommand("Pr_addClass",con);
cmd.CommandType=CommandType.StoredProcedure;
SqlParameter pcName=new SqlParameter("@pcName",SqlDbType.VarChar,50);
pcName.Value=TextBox2.Text;
cmd.Parameters.Add(pcName);
SqlParameter pcParentID=new SqlParameter("@pcParentID",SqlDbType.Int,4);
pcParentID.Value=pcID;
cmd.Parameters.Add(pcParentID);
con.Open();
int i=cmd.ExecuteNonQuery();
con.Close();
Response.Write(i.ToString());
pclassTree.Nodes.Clear();
bindpcclassTree();
}
private void Button3_Click(object sender, System.EventArgs e)
{
string selectID=pclassTree.SelectedNodeIndex;
string pcID=pclassTree.GetNodeFromIndex(selectID).NodeData;
Response.Write(pcID);
// int pcID=Convert.ToInt32(pid);
SqlConnection con=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["SQLCONSTR"]);
SqlCommand cmd=new SqlCommand("Pr_addClass",con);
cmd.CommandType=CommandType.StoredProcedure;
SqlParameter pcName=new SqlParameter("@pcName",SqlDbType.VarChar,50);
pcName.Value=TextBox2.Text;
cmd.Parameters.Add(pcName);
SqlParameter pcParentID=new SqlParameter("@pcParentID",SqlDbType.Int,4);
pcParentID.Value=pcID;
cmd.Parameters.Add(pcParentID);
con.Open();
int i=cmd.ExecuteNonQuery();
con.Close();
Response.Write(i.ToString());
pclassTree.Nodes.Clear();
bindpcclassTree();
}
N 久没有使用了
是我在树的节点上赋的值,即数据库里的分类ID号。
1.你没写SqlParameter变量是输入还是输出,如你应该这样写
Parameters["pcName"].Direction=ParameterDirection.Input;
2.你的节点要获得哪个值没有定义
<?IMPORT NAMESPACE=TVNS IMPLEMENTATION="/webctrl_client/1_0/treeview.htc" />
<tvns:treeview id="pclassTree" selectedNodeIndex="0" HelperID="__pclassTree_State__" systemImagesPath="/webctrl_client/1_0/treeimages/" selectExpands="true" autoSelect="true" onexpand="javascript: if (this.clickedNodeIndex != null) this.queueEvent('onexpand', this.clickedNodeIndex)" oncollapse="javascript: if (this.clickedNodeIndex != null) this.queueEvent('oncollapse', this.clickedNodeIndex)" oncheck="javascript: if (this.clickedNodeIndex != null) this.queueEvent('oncheck', this.clickedNodeIndex)" onselectedindexchange="javascript: if (event.oldTreeNodeIndex != event.newTreeNodeIndex) this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex + ',' + event.newTreeNodeIndex)" style="border-style:Groove;height:232px;width:200px;Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px">
<tvns:treenode Selected="true" NodeData="0">
项目分类<tvns:treenode Expanded="True" NodeData="1">
abc<tvns:treenode Expanded="True" NodeData="5">
asd
</tvns:treenode>
</tvns:treenode><tvns:treenode Expanded="True" NodeData="2">
asd
</tvns:treenode><tvns:treenode Expanded="True" NodeData="3">
asd
</tvns:treenode><tvns:treenode Expanded="True" NodeData="4">
asd
</tvns:treenode><tvns:treenode Expanded="True" NodeData="6">
asd
</tvns:treenode><tvns:treenode Expanded="True" NodeData="7">
321
</tvns:treenode><tvns:treenode Expanded="True" NodeData="8">
123
</tvns:treenode><tvns:treenode Expanded="True" NodeData="9">
1231
</tvns:treenode><tvns:treenode Expanded="True" NodeData="10">
1231
</tvns:treenode><tvns:treenode Expanded="True" NodeData="11">
1231
</tvns:treenode><tvns:treenode Expanded="True" NodeData="12">
20
</tvns:treenode><tvns:treenode Expanded="True" NodeData="13">
20
</tvns:treenode><tvns:treenode Expanded="True" NodeData="14">
10
</tvns:treenode><tvns:treenode Expanded="True" NodeData="15">
1
</tvns:treenode><tvns:treenode Expanded="True" NodeData="16">
1234
</tvns:treenode><tvns:treenode Expanded="True" NodeData="17">
asd
</tvns:treenode><tvns:treenode Expanded="True" NodeData="18">
ss
</tvns:treenode><tvns:treenode Expanded="True" NodeData="19">
ss
</tvns:treenode><tvns:treenode Expanded="True" NodeData="20">
d
</tvns:treenode>
</tvns:treenode>
</tvns:treeview>