Advertisement
Advertisement

新足迹

 找回密码
 注册
新足迹 门户 IT专业论坛 查看内容

小白的C#问题 (之二)

2011-6-16 14:35| 发布者: porcorosso | 查看: 1838| 原文链接

一个简单html form:
  1. <form name="myform">
  2.         <table>
  3.                 <tr>
  4.                         <td><input name="product[]" value="11"></td>
  5.                         <td><input name="price[]" value="22"></td>
  6.                 </tr>
  7.                 <tr>
  8.                         <td><input name="product[]" value="33"></td>
  9.                         <td><input name="price[]" value="44"></td>
  10.                 </tr>
  11.                 <tr>
  12.                         <td><input name="product[]" value="55"></td>
  13.                         <td><input name="price[]" value="66"></td>
  14.                 </tr>
  15.         </table>
  16.         <input type="submit">
  17. </form>       
复制代码
在PHP, 我们可以直接retrieve product and price as array。也就是说formdata processing时我们可以这样:
  1. <?php
  2.         for($i = 0; $i < count($_REQUEST['product']); $i++)
  3.         {
  4.                 echo "The price of product " . $_REQUEST['product'][$i] . " is " . $_REQUEST['price'][$i] . PHP_EOL;
  5.         }
  6. ?>
复制代码
Output:
  1. The price of product 11 is 22
  2. The price of product 33 is 44
  3. The price of product 55 is 66
复制代码
请问asp.net c# 应该怎么做? 看了一下<asp:textbox> 好像行不通。。。

Advertisement
Advertisement


Advertisement
Advertisement
返回顶部