asp.net - RadioButtonList value is null -


i building website multiple choices. page contains 2 radiobuttonlists generate when page loaded. however, when choose item, , click button, selecteditem has null values. code:

public partial class webform1 : system.web.ui.page {     multiplechoicedbcontext db = new multiplechoicedbcontext();     list<string> questionlist = new list<string>();     list<radiobuttonlist> optionlist = new list<radiobuttonlist>();     list<string> answerlist = new list<string>();     protected void page_load(object sender, eventargs e)     {         if (!ispostback)         {             var query = data in db.qas                         select data;             qa question;              int = 1;             listitem lia;             listitem lib;             listitem lic;             listitem lid;             while (i < 3)             {                 question = query.tolist()[(new random()).next(query.tolist().count)];                 questionlist.add(question.question);                 answerlist.add(question.answer);                  lia = new listitem(question.a, question.a);                 lib = new listitem(question.b, question.b);                 lic = new listitem(question.c, question.c);                 lid = new listitem(question.d, question.d);                  radiobuttonlist rdl = new radiobuttonlist();                 rdl.items.add(lia);                 rdl.items.add(lib);                 rdl.items.add(lic);                 rdl.items.add(lid);                  optionlist.add(rdl);                 phcontent.controls.add(rdl);                  i++;             }         }     }     protected void btnok_click(object sender, eventargs e)     {         (int = 0; < optionlist.count; i++)         {             string content = "";             content += optionlist[i].selecteditem.value + "<br />";             response.write(content);          }     } } 


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -