' Text ='<%#DataBinder.Eval(Container," DataItem.Name")%>' />
<div>
</div>
<asp:RadioButtonList ID="rblAnswers" runat="server" AnswerValue='<%#DataBinder.Eval(Container, "DataItem.ID")%>' RepeatDirection="Vertical">
</asp:RadioButtonList>
<asp:CustomValidator ID="cvAnswers" ClientValidationFunction="ClientValidate" ControlToValidate="rblAnswers" OnServerValidate="user" Text="Please Select record!" runat="server" />
</ItemTemplate>
</asp:Repeater>
答案 0 :(得分:0)
//这是后面的代码 protected void btnSubmit_Click(object sender,EventArgs e) {
foreach (RepeaterItem item in RepPlay.Items)
{
UserAnswers oUserAnswer = new UserAnswers();
oUserAnswer.User_ID = CMSContext.User;
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
var rblAnswers = item.FindControl("rblAnswers") as RadioButtonList;
string rblAnswer = rblAnswers.SelectedItem.Value;
if (rblAnswers.SelectedItem == null)
{
}
oUserAnswer.Answer_ID = Convert.ToInt32(rblAnswer);
var lblQuestion = (Label)item.FindControl("lblQuestion");
oUserAnswer.Question_ID = Convert.ToInt32(lblQuestion.Attributes["QuestionValue"]);
}
if (CMSContext.User <= 0)
oUserAnswer.Session = Session.SessionID;
int userAnswerId = Eskadenia.Framework.Survey.Data.UserAnswerManager.AddUserAnswer(oUserAnswer);
Eskadenia.Framework.Survey.Entitis.UserSurvey userSurvey = Eskadenia.Framework.Survey.Data.UserSurveyManager.GetByUserIdAndSurveyId(UserId, surveyId);
userSurvey.EndTime = DateTime.UtcNow;
Eskadenia.Framework.Survey.Data.UserSurveyManager.UpdateUserSurvey(userSurvey);
}