Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 将下拉列表和单选列表的值相乘以显示在文本框中?_Asp.net - Fatal编程技术网

Asp.net 将下拉列表和单选列表的值相乘以显示在文本框中?

Asp.net 将下拉列表和单选列表的值相乘以显示在文本框中?,asp.net,Asp.net,我有一个点表如下,有下拉列表和2个单选按钮列表。选择值后,我想显示倍增的值和每个文本框中的部分总数 比如说 DDL1*RB1*RB2=(值1) DDL2*RB3*RB4=(值2) 总计:(值1)+(值2) Example.aspx <asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"> <br /> <h3 style="text-align: center"

我有一个点表如下,有下拉列表和2个单选按钮列表。选择值后,我想显示倍增的值和每个文本框中的部分总数

比如说

DDL1*RB1*RB2=(值1)

DDL2*RB3*RB4=(值2)

总计:(值1)+(值2)

Example.aspx

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">

<br />
<h3 style="text-align: center">Point Table</h3>
<br />  
    <table style="width:100%;">            
         <tr>
            <td style="width:73px;">Section</td>
            <td style="width:145px;">WEIGHTED SCORE(A)</td>
            <td>FIELD(B)</td>
            <td>FIELD(C)</td>
            <td>FIELD(D) D=AxBxC</td>
        </tr>               
         <tr>               
            <td style="width: 73px">Section A</td>
             <td style="width: 145px">
                <asp:DropDownList ID="DropDownList1" runat="server" Height="22px" Width="80px">
                    <asp:ListItem Selected="True">Select</asp:ListItem>
                    <asp:ListItem>5</asp:ListItem>
                    <asp:ListItem>10</asp:ListItem>
                    <asp:ListItem>15</asp:ListItem>
                </asp:DropDownList>
            </td>                
             <td>
                 <asp:RadioButtonList ID="RadioButtonList1" runat="server" Height="16px" RepeatDirection="Horizontal" Width="270px">
                     <asp:ListItem Value="0,4"></asp:ListItem>
                     <asp:ListItem Value="0,7"></asp:ListItem>
                     <asp:ListItem Value="1"></asp:ListItem>
                 </asp:RadioButtonList>
             </td>
             <td>
                 <asp:RadioButtonList ID="RadioButtonList2" runat="server" Height="23px" RepeatDirection="Horizontal" Width="383px">
                     <asp:ListItem Value="0,6"></asp:ListItem>
                     <asp:ListItem Value="0,7"></asp:ListItem>
                     <asp:ListItem Value="0,8"></asp:ListItem>
                     <asp:ListItem Value="0,9"></asp:ListItem>
                     <asp:ListItem Value="1"></asp:ListItem>
                 </asp:RadioButtonList>
             </td>
             <td>
                 <asp:TextBox ID="TextBox1" runat="server" Width="63px"></asp:TextBox>
             </td>              
            </tr>
        <tr>
            <td style="width: 73px">
                Section B</td>
            <td style="width: 145px">
                <asp:DropDownList ID="DropDownList2" runat="server" Height="22px" Width="80px">
                    <asp:ListItem Selected="True">Select</asp:ListItem>
                    <asp:ListItem>5</asp:ListItem>
                    <asp:ListItem>10</asp:ListItem>
                    <asp:ListItem>15</asp:ListItem>
                </asp:DropDownList>
            </td>
            <td>
                <asp:RadioButtonList ID="RadioButtonList3" runat="server" Height="16px" RepeatDirection="Horizontal" Width="270px">
                    <asp:ListItem Value="0,4"></asp:ListItem>
                    <asp:ListItem Value="0,7"></asp:ListItem>
                    <asp:ListItem Value="1"></asp:ListItem>
                </asp:RadioButtonList>
            </td>
            <td>
                <asp:RadioButtonList ID="RadioButtonList4" runat="server" Height="23px" RepeatDirection="Horizontal" Width="383px">
                    <asp:ListItem Value="0,6"></asp:ListItem>
                    <asp:ListItem Value="0,7"></asp:ListItem>
                    <asp:ListItem Value="0,8"></asp:ListItem>
                    <asp:ListItem Value="0,9"></asp:ListItem>
                    <asp:ListItem Value="1"></asp:ListItem>
                </asp:RadioButtonList>
            </td>
            <td>
                <asp:TextBox ID="TextBox2" runat="server" Width="63px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 73px">
                &nbsp;</td>
            <td style="width: 145px">
                &nbsp;</td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width:73px">&nbsp;</td>
            <td style="width:145px">&nbsp;</td>
            <td>&nbsp;</td>
            <td style="text-align:right">TOTAL FIELD:</td>
            <td>
                <asp:TextBox ID="TextBox3" runat="server" Width="63px"></asp:TextBox>
            </td>
        </tr>           
    </table>    


点表
部分 加权分数(A) 字段(B) 字段(C) 字段(D)D=AxBxC A节 挑选 5. 10 15 B节 挑选 5. 10 15 总字段:

你需要发布数据,有很多方法。

example.aspx
设置autopostback属性

 <asp:RadioButtonList ID="RadioButtonList2" runat="server" Height="23px" 
                 RepeatDirection="Horizontal" Width="383px" AutoPostBack="True">
                 <asp:ListItem Value="0,6"></asp:ListItem>
                 <asp:ListItem Value="0,7"></asp:ListItem>
                 <asp:ListItem Value="0,8"></asp:ListItem>
                 <asp:ListItem Value="0,9"></asp:ListItem>
                 <asp:ListItem Value="1"></asp:ListItem>
 </asp:RadioButtonList>
 <asp:RadioButtonList ID="RadioButtonList4" runat="server" Height="23px" 
                RepeatDirection="Horizontal" Width="383px" AutoPostBack="True">
                <asp:ListItem Value="0,6"></asp:ListItem>
                <asp:ListItem Value="0,7"></asp:ListItem>
                <asp:ListItem Value="0,8"></asp:ListItem>
                <asp:ListItem Value="0,9"></asp:ListItem>
                <asp:ListItem Value="1"></asp:ListItem>
  </asp:RadioButtonList>

您想在客户端还是服务器端执行此操作?在服务器端,您可以获得DropDownList1.SelectedValue和RadioButtonList1.SelectedValue等值。您必须拆分RB值才能获得点坐标。我想在服务器端执行此操作。如何分割RB值?每个人都有身份证号码。谢谢你的回复。如何将其集成到代码隐藏中?可以在Example.aspx.cs中使用这样的东西吗?受保护的void UpdateTotals(对象发送方,事件参数e){if(DropDownList1.Visible=true){decimal multiply=decimal.Parse(DropDownList1.SelectedValue)*decimal.Parse(RadioButtonList1.SelectedValue)*decimal.Parse(RadioButtonList2.SelectedValue);TextBox1.Text=multiply.ToString();}}}非常感谢Tyres。但是在应用代码隐藏时,我出现了一个错误,显示为asp.net错误CS0123:“没有重载匹配“UpdateTotals”的委托“System.EventHandler”好的,通过删除OnSelectedIndexChanged=“UpdateTotals”按下按钮,错误已经修复。现在它正在工作。我非常感谢你。非常感谢你。
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

        }
        else { 
            UpdateTotals();
        }

    }
    protected void UpdateTotals()
    {
        decimal multiply=0m;
        decimal multiply2=0m;
        //you have to check the value
        if (DropDownList1.SelectedValue != "Select" && RadioButtonList1.SelectedValue != "" && RadioButtonList2.SelectedValue != "")
        {
            multiply = Decimal.Parse(DropDownList1.SelectedValue) * Decimal.Parse(RadioButtonList1.SelectedValue) * Decimal.Parse(RadioButtonList2.SelectedValue);
            TextBox1.Text = multiply.ToString();
        }

        if (DropDownList2.SelectedValue != "Select" && RadioButtonList3.SelectedValue != "" && RadioButtonList4.SelectedValue != "")
        {
            multiply2 = Decimal.Parse(DropDownList2.SelectedValue) * Decimal.Parse(RadioButtonList3.SelectedValue) * Decimal.Parse(RadioButtonList4.SelectedValue);
            TextBox2.Text = multiply2.ToString();
        }
        TextBox3.Text = string.Format("{0}", multiply + multiply2);
    }