評価応答を送信して SQL データベースを更新するリピーターで学生評価フォームを作成していますが、タイトルに記載されているエラーが引き続き発生します。VB を使用して ASP.Net でコーディングしています。
ここに私のコードがあります: Student.aspx
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<asp:Wizard ID="StudentEvaluationWizard" runat="server" ActiveStepIndex="0">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Course">
<asp:GridView ID="CourseView" runat="server" AutoGenerateColumns="False"
DataKeyNames="SectionID" >
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="EnrollmentID" HeaderText="EnrollmentID"
InsertVisible="False" ReadOnly="True" SortExpression="EnrollmentID" />
<asp:BoundField DataField="StudentID" HeaderText="StudentID"
SortExpression="StudentID" />
<asp:BoundField DataField="SectionID" HeaderText="SectionID"
SortExpression="SectionID" />
<asp:TemplateField ConvertEmptyStringToNull="False" HeaderText="Section" >
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Section.Course.Name") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Evaluation">
<asp:Repeater ID="EvalRepeater" runat="server"
DataSourceID="EvaluationQuestions">
<HeaderTemplate><caption><asp:Label ID="EvaluationTitle" runat="server" Text='<%Eval("Evaluation.Evaluation1.") %>' /><caption></HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="QuestionID" runat="server" Text='<%# Eval("QuestionID") %>' Visible="false" />
</td>
<td>
<asp:Label ID="Questions" runat="server" Text='<%# Eval("Question1") %>' />
</td>
<td>
<%--Move outside of table to make edits--%>
<asp:RadioButtonList ID="Question" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:TextBox ID="StudentComment" runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:Button ID="SubmitButton" runat="server" Text="Submit Evaluation" />
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
<asp:LinqDataSource ID="CourseSelect" runat="server" ContextTypeName="EvaluationDAL.Model.EvaluationDataDataContext"
EntityTypeName="Enrollment" TableName="Enrollments" Where="StudentID == @StudentID">
<WhereParameters>
<asp:SessionParameter DefaultValue="StudentID" Name="StudentID" SessionField="StudentID"
Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
<asp:LinqDataSource ID="EvaluationQuestions" runat="server" ContextTypeName="EvaluationDAL.Model.EvaluationDataDataContext"
EntityTypeName="" TableName="Questions"
Where="EvaluationID == Convert.ToInt32(@EvaluationID)">
<WhereParameters>
<asp:SessionParameter Name="EvaluationID" SessionField="EvaluationID"
Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
</asp:Content>
Student.aspx.vb (エラーのある [送信] ボタン)
Protected Sub SubmitButton_Click(sender As Object, e As System.EventArgs) Handles SubmitButton.Click
Dim sr As New StudentEvaluation
sr.SectionID = EvaluationGlobal.SectionID
sr.EvaluationDate = DateAndTime.Now
'Create a new evaluation object
Dim eval As New StudentEvaluation
For Each row As RepeaterItem In EvalRepeater.Items
'Get the question
Dim questionID As Label = CType(row.FindControl("QuestionID"), Label)
Dim question1 As Integer = Convert.ToInt32(question1)
eval.Comments = Convert.ToInt32(row.FindControl("Comments"))
'Find radio button list with the name Question and convert to radio button list
Dim rank As RadioButtonList = CType(row.FindControl("Question"), RadioButtonList)
'Get the infomation if the area is not empty
If Not String.IsNullOrWhiteSpace(rank.SelectedValue) Then
Dim ser As New StudentEvaluationResponse
ser.QuestionID = Convert.ToInt32(row.FindControl("QuestionID"))
ser.Answer = Convert.ToInt16(row.FindControl("Question"))
Dim questionRank As Integer = Convert.ToInt32(rank.SelectedValue)
Dim studentComment As TextBox = CType(row.FindControl("StudentComment"), TextBox)
Dim comment As String = studentComment.Text
eval.StudentEvaluationResponses.Add(ser)
End If
Next
If eval.StudentEvaluationResponses.Count > 0 Then
eval.Insert()
End If
End Sub
これを修正する方法が完全にわかりません。どんな助けでも素晴らしいでしょう。