如何收集 JUST 文本框控件的值?
有没有办法在 ASP.NET 4.0 中指定这个?
ArrayList alAnswerList = new ArrayList();
int iCount = 0;
NameValueCollection frmCollect = Request.Form;
iCount = frmCollect.Count;
for (int i = 0; i <= iCount; i++)
{
alAnswerList.Add(frmCollect.GetValues(i));
}
我试图避免硬编码一个确切的索引值来开始获取值。
谢谢!
更新:控制代码
<div id="Layer1" runat="server" style="overflow-x: hidden; overflow-y: hidden; padding: 0px 50px 0 50px">
<div id="buttonWrapper">
<asp:Label runat="server" ID="lblStartHunting">text</asp:Label>
<asp:Button runat="server" ID="btnStart" Text="Start" OnClick="btnStart_Click" BorderColor="WhiteSmoke" />
<br />
<br />
<br style="clear: both;" />
<asp:Label runat="server" ID="lblName">Name / Team Name to be added:</asp:Label>
<asp:TextBox runat="server" ID="txtName" Width="280px" BorderColor="WhiteSmoke"></asp:TextBox>
</div>
<div id="huntHeaderWrapper"><div id="huntHeaderPoints"><strong>Points</strong></div><div id="huntHeaderQuestion"><strong>Question</strong></div><div id="huntHeaderAnswer"><strong>Answer</strong></div></div>
<asp:DataList ID="dlHunt" runat="server" Width="740px" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:Label ID="idLabel" runat="server" Text='<%# Eval("id") %>' Visible="false" />
<div id="huntDivPoints">
<asp:Label ID="pointsLabel" runat="server" Text='<%# Eval("points") %>' />
</div>
<div id="huntDivQuestion">
<asp:Label ID="questionLabel" runat="server" Text='<%# Eval("question") %>' />
</div>
<div id="huntDivAnswer">
<asp:TextBox ClientIDMode="Static" ID="huntAnswerText" runat="server" Width="240px" BorderColor="WhiteSmoke"></asp:TextBox><br />
<span style="color: #395069;">Hint: <asp:Label ID="hintLabel" runat="server" Text='<%# Eval("hint") %>' /></span>
</div>
</ItemTemplate>
<ItemStyle BackColor="White" BorderColor="#5885a3" BorderWidth="1" BorderStyle="Solid" />
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Connection_private %>" SelectCommand="SELECT [id], [question], [hint], [answer], [points] FROM [table]"></asp:SqlDataSource>
<asp:Button ID="btnShowAnswers" runat="server" Text="Submit Answers" BorderColor="WhiteSmoke" OnClick="btnShowAnswers_Click" /> <asp:Label runat="server" ID="lblSubmit"> text</asp:Label>
</div>