还关于treeview里checkbox的问题
想问一下,我用的多选框的text值怎么样都进入数据库呀,我做的只能进一个,想问问怎么样循环呀,不太明白呀,先多谢了~~
代码如下:
if (TreeView1.CheckedNodes.Count > 0)
{
foreach (TreeNode tn in TreeView1.CheckedNodes)
{
if(tn.Checked == true)
{
addtext = tn.Text;
}
}
}
string EIPConnectionString = ConfigurationSettings.AppSettings[ "EIPConnectionString "].ToString();
SqlConnection conn = new SqlConnection(EIPConnectionString);
conn.Open();
SqlCommand cmd1 = new SqlCommand( "select KindID,ParentID from sys_menu where Context= ' " + addtext + " ' ", conn);
SqlDataReader readr = cmd1.ExecuteReader();
while (readr.Read())
{
// pid = readr[ "pid "].ToString();
kindid = readr[ "KindID "].ToString();
preatenid = readr[ "ParentID "].ToString();
}
readr.Close();
id = Request[ "groupid "].ToString();
SqlCommand cmd = new SqlCommand( "insert into groups_menu(KindID,ParentID,id)values( ' " + kindid + " ', ' " + preatenid + " ', ' "+id+ " ') ", conn);
cmd.ExecuteNonQuery();
Response.Write( " <script> window.alert( '送出成功! '); </script> ");
conn.Close();
------解决方案--------------------