form表单中隐藏类型input的使用

<form action="PersonSave.ashx" method="post">
        <input type="hidden" name="action" value="{action}"/>
        <input type="hidden" name="id" value="{id}"/>
        姓名:<input type="text" name="name" value="{name}" />年龄:<input type="text" name="age" value="{age}" />
        性别:(选上就是男的)<input type="checkbox" name="gender" {gender} />
        <input type="submit" value="保存" />
    </form>

表单保存时,若action为edit,那么后台则需要一个id来具体update哪条数据

        if (action=="edit")
            {
                int id = Convert.ToInt32(context.Request["id"]);
                SqlHelper.ExecuteNonQuery("update T_Persons set Name=@Name,Age=@Age,Gender=@Gender where Id=@Id",
                    new SqlParameter("@Name", strName),
                    new SqlParameter("@Age", strAge),
                    new SqlParameter("@Gender", (strGender!=null)),
                    new SqlParameter("@Id", id));
                context.Response.Redirect("PersonList.ashx");
            }