0

我在面板中有一张桌子。该表有 32 行和 4 列。一列是标签并有描述。其他 3 个是文本框。用户可以在任何文本框中输入 0 到 99 之间的数字。不需要任何文本框,因此用户可以选择不输入任何内容。输入后,用户将单击下一步按钮,计算将完成并显示在新页面中。在此之前,我想知道如何保存用户输入的所有数据。那么我如何读取每个保存的行来进行计算呢?这是我被困在如何使用列表 int 或列表字符串保存在会话中以及如何计算会话中输入的数据的地方。数据库中没有保存任何内容。 示例代码

<table class="wizard">
<tbody> 
    <tr>
      <td class="blankcell" valign="bottom" align="left" width="39%">
      <span class="smalllabel">Available Service</span></td>
      <td class="blankcell" valign="bottom" align="right" width="10%">
      <span class="smalllabel">You</span></td>
      <td class="blankcell" valign="bottom" align="right" width="10%">
      <span class="smalllabel">Spouse</span></td>
      <td class="blankcell" valign="bottom" align="right" width="10%">
      <span class="smalllabel">Child</span></td>
    </tr>
    <tr>
      <td class="grayservicebackground" align="left" valign="middle" style="width:39%;">
      <span class="servicefont">Preventive Physical Exam</span></td>
      <td id="SinglePreventivePhysicalExam" class="numberofserviceinputcell" align="right" valign="bottom" style="width:10%;">
      <asp:TextBox ID="txtSinglePreventivePhysicalExam" runat="server" value="0" maxlength="2" size="3" class="numberinput"></asp:TextBox>
      <cc2:FilteredTextBoxExtender ID="FilteredTextBoxExtender0" runat="server"
      FilterType="Numbers" TargetControlID="txtSinglePreventivePhysicalExam" />
      </td>

      <td id="SpousePreventivePhysicalExam" class="numberofserviceinputcell" align="right" valign="bottom" style="width:10%;">
      <asp:TextBox ID="txtSpousePreventivePhysicalExam" runat="server" value="0" maxlength="2" size="3" class="numberinput"></asp:TextBox>
      <cc2:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server"
      FilterType="Numbers" TargetControlID="txtSpousePreventivePhysicalExam" /></td>

      <td id="ChildPreventivePhysicalExam" class="numberofserviceinputcell" align="right" valign="bottom" style="width:10%;">
      <asp:TextBox ID="txtChildPreventivePhysicalExam" runat="server" value="0" maxlength="2" size="3" class="numberinput"></asp:TextBox>
      <cc2:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server"
      FilterType="Numbers" TargetControlID="txtChildPreventivePhysicalExam" /></td>
    </tr>

    <tr>
      <td class="grayservicebackground" align="left" valign="middle" style="width:39%;">
      <span class="servicefont">Preventive Well Child Visit through Age 5</span></td>
      <td id="SinglePreventiveWellChildVisitthroughAge5" class="numberofserviceinputcell" align="right" valign="bottom" style="width:10%;">
      <asp:TextBox ID="txtSinglePreventiveWellChildVisitthroughAge5" runat="server" value="0" maxlength="2" size="3" class="numberinput"></asp:TextBox>
      <cc2:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server"
      FilterType="Numbers" TargetControlID="txtSinglePreventiveWellChildVisitthroughAge5" />
      </td> 
      <td id="SpousePreventiveWellChildVisitthroughAge5" class="numberofserviceinputcell" align="right" valign="bottom" style="width:10%;">
      <asp:TextBox ID="txtSpousePreventiveWellChildVisitthroughAge5" runat="server" value="0" maxlength="2" size="3" class="numberinput"></asp:TextBox>
      <cc2:FilteredTextBoxExtender ID="FilteredTextBoxExtender4" runat="server"
      FilterType="Numbers" TargetControlID="txtSpousePreventiveWellChildVisitthroughAge5" />
      </td>
      <td id="ChildPreventiveWellChildVisitthroughAge5" class="numberofserviceinputcell" align="right" valign="bottom" style="width:10%;">
      <asp:TextBox ID="txtChildPreventiveWellChildVisitthroughAge5" runat="server" value="0" maxlength="2" size="3" class="numberinput"></asp:TextBox>
      <cc2:FilteredTextBoxExtender ID="FilteredTextBoxExtender5" runat="server"
      FilterType="Numbers" TargetControlID="txtChildPreventiveWellChildVisitthroughAge5" />
      </td> 
    </tr>
    </tbody>
 </table>

4

1 回答 1

0

假设你正在使用ASP.NET Web Forms?

如果您已Viewstate启用,则文本框将在某些情况下保留这些值。

您的下一个按钮将具有某种与您的代码相关联的 OnClick 功能,对吗?

protected btnNext_Click(object sender, Eventargs e) {

  var value = txtSpousePreventivePhysicalExam.Text;

}

这就是你如何获得特定文本框的值。然后,您可以将该值存储在其中Session以保持该值有效。

于 2013-09-06T16:11:56.193 回答