我正在尝试RadioButtonList
从数据库中填充一个并将其输出到ListView
:
我试过的:
ASP:
<ItemTemplate>
<asp:RadioButtonList runat="server" DataSource=<%#Eval("respostas")%>></asp:RadioButtonList>
</ItemTemplate>
C#:
DataRow dr = dt.NewRow();
dr["nome_pergunta"] = reader["pergunta"];
DataTable respostas = new DataTable();
respostas.Columns.Add("respostaA", typeof(string));
respostas.Columns.Add("respostaB", typeof(string));
respostas.Columns.Add("respostaC", typeof(string));
respostas.Columns.Add("respostaD", typeof(string));
DataRow linha = respostas.NewRow();
linha["respostaA"] = reader["respostaA"].ToString();
linha["respostaB"] = reader["respostaB"].ToString();
respostas.Rows.Add(linha);
dr["respostas"] = respostas;
dt.Rows.Add(dr);
我也试过: ASP:
<ItemTemplate>
<%#Eval("respostas")%>
</ItemTemplate>
C#:
RadioButtonList respostas = new RadioButtonList();
respostas.ID = "respostas_" + numero_respota;
respostas.Items.Add(new ListItem(reader["respostaA"].ToString(), "a"));
respostas.Items.Add(new ListItem(reader["respostaB"].ToString(), "b"));
respostas.Items.Add(new ListItem(reader["respostaC"].ToString(), "c"));
respostas.Items.Add(new ListItem(reader["respostaD"].ToString(), "d"));
他们都没有工作,有什么建议吗?