已知:是个关于酒店订房的系统,有入住时间、离店时间、选中 3项其中选中那项里面的值是某个客房的单订价格,我现在需要的是 通过选择入住时间和离店时间,算出其中的天数,然后乘上客房单价,得出总价格。。这个计算必须要有以下条件才可以成立:1、入住时间与离店时间必选,选中那项,有选择的才计算,怎么同时历遍并区分这3个元素,卡在这里了,
我的项目测试地址:http://www.hksyw.com/package/detail.aspx?PackageID=10000
如果想看效果:请选择时间后进入下一步,登陆帐号:test 密码:missqing请利用有限的时间帮我看看,我都卡死在这里了。。

解决方案 »

  1.   

    这3项都是些什么?数据库字段,还是用户在DataGrid中列的输入?请描述清楚,应该不难的~
      

  2.   

    2个时间字段,是用户输入的啊,,而checkbox已隐藏着一个值,选中的话,就取到了这个值,现在需要同时取到这3个值,但是对于javascript我真的不明白怎么才可以同时历遍...感谢楼上的,还回答这个问题
      

  3.   

    不是非常清楚楼主的问题。历遍DataGrid的例子:
    <asp:datagrid id="grid" runat="server" PageSize="15" DataKeyField="ID" Width="100%" AutoGenerateColumns="False" AllowPaging="True">
    <Columns>
    <asp:TemplateColumn  title='选'">
    <HeaderStyle Width="20px"></HeaderStyle>
    <ItemTemplate>
    <asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
    </ItemTemplate>
    /asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="编号">
    <HeaderStyle HorizontalAlign="Center" Width="25px"></HeaderStyle>
    <ItemStyle HorizontalAlign="Center"></ItemStyle>
    <ItemTemplate>
    <%# grid.CurrentPageIndex*grid.PageSize+grid.Items.Count+1 %>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="学号">
    <HeaderStyle Width="40px"></HeaderStyle>
    <ItemTemplate>
    <asp:Label id=lblCode runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Code") %>'>
    </asp:Label>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    <PagerStyle Visible="False"></PagerStyle>
    </asp:datagrid> CheckBox chkExport;
    String sID;
    //循环取的DataGrid控件中选定项的值
    foreach(DataGridItem oDataGridItem in grid.Items)
    {chkExport = (CheckBox)oDataGridItem.FindControl("CheckBox1");
    //如果选中了则取值
    if(chkExport.Checked)
    {
    sID = ((Label)(oDataGridItem.FindControl("lblCode"))).Text;
    }
    }
      

  4.   

    是单一,
    如果你有多个,你可以放多个DATAGRID,然后各个遍历。
    最后拼成SQL语句。