Iwant to do survey.
there is an placeholder(place holder has dynamic created label and dynamic created radiobuttonlist) inside survey usercontrol.I checked how many question are there.
usercontrol-->placeholder-->label and radiobuttonlist(created dynamicly because we dont know how many question are there)
there is no problem up to here Iam getting questions and create label and radiobuttonlist
MySqlCommand command = new MySqlCommand("xxxxx", conn);
command.CommandType = System.Data.CommandType.StoredProcedure;
command.Parameters.Add("@surveyno", MySqlDbType.VarChar).Value = yyy;
conn.Open();
MySqlDataAdapter dAdapter = new MySqlDataAdapter(command);
DataSet dset = new DataSet();
dAdapter.Fill(dset);
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Label myLabel = new Label();
RadioButtonList rdr = new RadioButtonList();
rdr.Items.Add(new ListItem("Yes", "1"));
rdr.Items.Add(new ListItem("No", "2"));
rdr.RepeatDirection=System.Web.UI.WebControls.RepeatDirection.Horizontal;
rdr.DataBind();
myLabel.Text = reader["sorular"].ToString();
PlaceHolder1.Controls.Add(myLabel);
PlaceHolder1.Controls.Add(rdr);
PlaceHolder1.Controls.Add(new LiteralControl("
"));
}
but I select answers question one yes question two no etc. click save button it dont find radiobuttonlist in the placeholder.
Code like this
foreach (Control ctrl in this.PlaceHolder1.Controls)
{
if (ctrl is RadioButtonList)
{
string soruid = ((RadioButtonList)ctrl).ID;
string puan = ((RadioButtonList)ctrl).SelectedValue;
if (puan == null || puan == "")
puan = "0";
}
}