在此處繪製完整的空白,這應該非常簡單,但是我嘗試的任何操作都不起作用。無法從中繼器中的文本框中獲取文本
我只是想從TextBox
得到的值在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,但都沒有工作。
請任何人都可以幫忙。
獲取行索引 - 請參閱:http://stackoverflow.com/questions/13648037/how-to-get-updated-textbox-value-from-repeater – NoChance