protected void Button5_Click(object sender, EventArgs e) { SqlDataSourceChain.Delete(); for (int i = 0; i < GridView3.Rows.Count; i++) { TableCell TableCell1 = (TableCell)GridView3.Rows[i].Cells[0]; CheckBox CheckBox1 = (CheckBox)TableCell1.FindControl("CheckBox1"); if (!CheckBox1.Checked) { continue; } HiddenField HiddenField2 = (HiddenField)TableCell1.FindControl("HiddenField2"); ListView ListView3 = (ListView)TableCell1.FindControl("ListView3"); SqlDataSourceChain.InsertParameters["IdParentQuest"].DefaultValue = HiddenField2.Value; int cnt_answer_checked = 0; for (int j = 0; j < ListView3.Items.Count; j++) { ListViewDataItem ListItem1 = (ListViewDataItem)ListView3.Items[j]; CheckBox ActiveCheckBox = (CheckBox)ListItem1.FindControl("ActiveCheckBox"); if (!ActiveCheckBox.Checked) { continue; } HiddenField HiddenField3 = (HiddenField)ListItem1.FindControl("HiddenField3"); SqlDataSourceChain.InsertParameters["IdParentAnswer"].DefaultValue = HiddenField3.Value; SqlDataSourceChain.Insert(); cnt_answer_checked++; } if (cnt_answer_checked == 0) { SqlDataSourceChain.Insert(); } } }
protected void Button9_Click(object sender, EventArgs e) { Button Button9 = (Button)sender; string IdParentAnswer = Button9.CommandArgument.ToString(); string IdParentQuest = ((Label)Button9.Parent.FindControl("IdQuestLabel")).Text; if (HiddenFieldIdSession.Value != "" && IsSaveAnswer) { saveAnswer(Convert.ToInt32(HiddenFieldIdScenario.Value), Convert.ToInt32(HiddenFieldIdSession.Value), Convert.ToInt32(IdParentQuest), Convert.ToInt32(IdParentAnswer)); } SqlDataSourceChain.SelectParameters["IdParentAnswer"].DefaultValue = IdParentAnswer; SqlDataSourceChain.SelectParameters["IdParentQuest"].DefaultValue = IdParentQuest; DataView DataView1 = (DataView)SqlDataSourceChain.Select(DataSourceSelectArguments.Empty); if (DataView1.Table.Rows.Count == 0) { Session.Contents["-1"] = IdParentQuest; Session.Contents["-1IdScenario"] = HiddenFieldIdScenario.Value; HiddenFieldIdParentQuest.Value = "-1"; return; } ; int IdQuest = (int)DataView1.Table.Rows[0]["IdQuest"]; int IdScenario = (int)DataView1.Table.Rows[0]["IdScenario"]; if (IdQuest > 0) { Session.Contents[IdQuest.ToString()] = IdParentQuest; Session.Contents[IdQuest.ToString() + "IdScenario"] = HiddenFieldIdScenario.Value; //Label17.Text = Session.Contents[IdQuest.ToString() + "IdScenario"].ToString(); HiddenFieldIdParentQuest.Value = IdQuest.ToString(); HiddenFieldIdScenario.Value = IdScenario.ToString(); //Label17.Text = HiddenFieldIdParentQuest.Value; //ListView1.DataBind(); } /* * * Button Button9 = (Button)sender; * string IdParentAnswer = Button9.CommandArgument.ToString(); * string IdParentQuest = ((Label)Button9.Parent.FindControl("IdQuestLabel")).Text; * SqlDataSourceChain.SelectParameters["IdParentAnswer"].DefaultValue = IdParentAnswer; * SqlDataSourceChain.SelectParameters["IdParentQuest"].DefaultValue = IdParentQuest; * DataView DataView1 = (DataView)SqlDataSourceChain.Select(DataSourceSelectArguments.Empty); * if (DataView1.Table.Rows.Count == 0) * { * Session.Contents["-1"] = IdParentQuest; * HiddenFieldIdParentQuest.Value = "-1"; * return; * }; * int IdQuest = (int)DataView1.Table.Rows[0]["IdQuest"]; * if (IdQuest > 0) * { * * Session.Contents[IdQuest.ToString()] = IdParentQuest; * //Label17.Text = Session.Contents[IdQuest.ToString()].ToString(); * HiddenFieldIdParentQuest.Value = IdQuest.ToString(); * //Label17.Text = HiddenFieldIdParentQuest.Value; * //ListView1.DataBind(); * * } * * */ }