|
I want to ask, how does the text value of the multi-select box I use enter the database? I can only enter one. I want to ask how to loop, I don't understand, thank you ~~
code show as below:
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 ('Send successfully!'); </ Script>");
conn.Close (); |
|