메신저, 난 분명이 코드가 얼마나에 실험, 아무 의미도하지 않습니다이ASP.Net 라디오 버튼 목록
for (int i = 1; i < 3; i++)
{
TableRow tr = new TableRow();
Table1.Rows.Add(tr);
TableCell QuestionCell = new TableCell();
// get the text for the question and stick it in the cell
QuestionCell.Text = "<b>"+i+".</b> Question " + i;
tr.Cells.Add(QuestionCell);
TableRow tr2 = new TableRow();
Table1.Rows.Add(tr2);
// create a cell for the choice
TableCell ChoicesCell = new TableCell();
ChoicesCell.Width = 1000;
// align the choices on the left
ChoicesCell.HorizontalAlign = HorizontalAlign.Left;
tr2.Cells.Add(ChoicesCell);
RadioButtonList rbl = new RadioButtonList();
rbl.ID = "Radio1_" + i;
ChoicesCell.Controls.Add(rbl);
rbl.Items.Add("1");
rbl.Items.Add("2");
rbl.Items.Add("3");
rbl.Items.Add("4");
}
와 비슷한 몇 가지 모의 코드를 나는이 피드백 양식을 할 수있다, 문제는 지금 한 번 누군가가 제출 버튼을 누른다. (양식에 제출 버튼이있다.) 나는 어떻게 테이블을 지나가고 사용자가 선택한 라디오 버튼에서 텍스트를 얻는다? from page_load!에서 생성 된 피드백!
도움을 주셔서 감사합니다. 메신저 잘못가는 경우 버튼이 작동하지 않는 것
protected void Button1_Click(object sender, EventArgs e)
{
foreach (TableCell cell in Table1.Rows)
{
foreach (Control ctrl in cell.Controls)
{
if (ctrl is RadioButtonList)
{
if (ctrl.selected) // this doesnt works
{
string selected = ctrl.text // this doesnt work either
}
}
}
}
}
이 을 누르면 한 번
편집 그래서 나는이 코드를 가지고 ... 난 몰라!
대신
SelectedValue
속성을 사용해보십시오. 무슨 소리 야? 특정 오류가 발생 했습니까? – jessegavin