在这里画一个完整的空白应该非常简单,但我尝试的一切都行不通。
我只是想从 aTextBox
中获取价值Repeater
。
<asp:Repeater ID="rptQuestions" runat="server">
<ItemTemplate>
<li>
<div class="">
<asp:Label ID="intQuestion" runat="server" Visible="false" Text='<%#Eval("intQuestion")%>'></asp:Label>
<asp:Label ID="intQuestionType" runat="server" Visible="false" Text='<%#Eval("intQuestionType")%>'></asp:Label>
<p>
<asp:Label ID="lblQuestion" runat="server" Text='<%#Eval("strQuestion").ToString().Replace("[*Garage*]", GarageName)%>'></asp:Label>
</p>
<asp:RadioButtonList ID="rblAnswers" RepeatDirection="Horizontal" TextAlign="Left" runat="server"></asp:RadioButtonList>
<asp:CheckBoxList ID="cblAnswers" RepeatDirection="Horizontal" TextAlign="Left" runat="server" ></asp:CheckBoxList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="rblAnswers" CssClass="parsley-error" ErrorMessage="This value is required"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtAnswers" TextMode="MultiLine" runat="server"></asp:TextBox>
</div>
</li>
</ItemTemplate>
</asp:Repeater>
我的点击代码如下
foreach (RepeaterItem ri in rptQuestions.Items)
{
var QuestionId = (Label)ri.FindControl("intQuestion");
var QuestionType = (Label)ri.FindControl("intQuestionType");
int intQuestion = Convert.ToInt32(QuestionId.Text);
int intQuestionType = Convert.ToInt32(QuestionType.Text);
var txtAnswer = (TextBox)ri.FindControl("txtAnswers");
if (txtAnswer == null)
{
intAnswer = 0;
strAnswer = Request.Form[txtAnswer.Text];
strAnswer = strAnswer + txtAnswer.Text;
strAnswer = strAnswer + "No Data";
}
else
{
intAnswer = 0;
strAnswer = Request.Form[txtAnswer.Text];
strAnswer = strAnswer + "-" + Request.Form[txt.Text];
strAnswer = strAnswer + "Test Stuff";
strAnswer = strAnswer + txtAnswer.Text;
}
}
值从标签中返回没有问题,但文本框无法正常工作,因为您可以看到我同时使用了 Request.Form[txtAnswer.Text] 和 txtAnswer.Text 但两者都不起作用。
请任何人都可以帮忙。