仅当下拉选择索引更改时,标签值才会更改 [英] label value changes only when dropdown selected index is changed

查看:73
本文介绍了仅当下拉选择索引更改时,标签值才会更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个价格计算器。它有一个下拉列表和三个radiobutton列表。当我选择任何单选按钮时,我需要更改总值。但它只会在下拉列表中更改价值改变。请帮我解决这个问题。



我的代码是





Hi,
I am having a price calculator.It has a dropdownlist and three radiobutton list.I need the total value Changed when i select any of the radiobuttons .But it only changes when the dropdown value is changed.kindly help me to solve this problem.

My code is


protected void Page_Load(object sender, EventArgs e)
   {
       rntotalprice.Text = "125";




       }

   private void Radbutselect1()
   {
       if (DropDownList1.Text == "300 gsm Card" || DropDownList1.Text == "300 gsm Kentex")
       {
           if ( RBList1.SelectedIndex == 0)
           {
               int x = Convert.ToInt32(rntotalprice.Text);
               int y = x + a;
               rntotalprice.Text = Convert.ToString(y);
           }
           if (RBList1.SelectedIndex == 1)
           {
               int x = Convert.ToInt32(rntotalprice.Text);
               int y = x + b;
               rntotalprice.Text = Convert.ToString(y);
           }
           if (RBList1.SelectedIndex == 2)
           {
               int x = Convert.ToInt32(rntotalprice.Text);
               int y = x + b;
               rntotalprice.Text = Convert.ToString(y);
           }
       }
   }
   protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
   {

      // dropdownselect();
       if (DropDownList1.Text == "300 gsm Card" )
       {
           Panel1.Visible = true;
           paneltxt.Visible = true;
           //processpnl.Visible = false;
           rntotalprice.Text = "125";

       }

       else if (DropDownList1.Text == "300 gsm Kentex" )
       {
           Panel1.Visible = true;
           paneltxt.Visible = true;
           // processpnl.Visible = false;
           rntotalprice.Text = "250";



       }
       else if (DropDownList1.Text == "Textured 1" )
       {

           Panel1.Visible = false;
           paneltxt.Visible = true;
           //processpnl.Visible = false;

       }
       else if (DropDownList1.Text == "Textured 2")
       {

           Panel1.Visible = false;
           paneltxt.Visible = true;
           rntotalprice.Text = "250";

       }
       else if (DropDownList1.Text == "Textured 3" )
       {

           Panel1.Visible = false;
           paneltxt.Visible = true;
           // processpnl.Visible = true;
           rntotalprice.Text = "250";
       }




   }



   protected void RadioButtonList3_SelectedIndexChanged(object sender, EventArgs e)
   {



       if (DropDownList1.Text == "300 gsm Card" || DropDownList1.Text == "300 gsm Kentex" || DropDownList1.Text == "Textured 1" || DropDownList1.Text == "Textured 2" || DropDownList1.Text == "Textured 3")
       {
           if (nonequick.SelectedIndex == 0)
           {
               int x = Convert.ToInt32(rntotalprice.Text);
               int y = x + a;
               rntotalprice.Text = Convert.ToString(y);

           }
           else if (nonequick.SelectedIndex == 1)
           {
               int x = Convert.ToInt32(rntotalprice.Text);
               int y = x + g;
               rntotalprice.Text = Convert.ToString(y);
           }

       }
       //    if (RadioButtonList3.SelectedItem.Text == "&nbsp None")
       //    {
       //        int x=Convert.ToInt32(rntotalprice.Text);
       //        int y= x + a;
       //        rntotalprice.Text = Convert.ToString(y);
       //    }
       //    if (RadioButtonList3.SelectedIndex == 1)
       //    {
       //        int x = Convert.ToInt32(rntotalprice.Text);
       //        int y = x + b;
       //        rntotalprice.Text = Convert.ToString(y);
       //    }
       //    if (RadioButtonList3.SelectedIndex == 2)
       //    {
       //        int x = Convert.ToInt32(rntotalprice.Text);
       //        int y = x + b;
       //        rntotalprice.Text = Convert.ToString(y);
       //    }
   }
   protected void RadioButtonList2_SelectedIndexChanged(object sender, EventArgs e)
   {

           if (RadioButtonList2.Text == "Straight")
           {
               int x = Convert.ToInt32(rntotalprice.Text);
               int y = x + a;
               rntotalprice.Text = Convert.ToString(y);

           }
           else if (RadioButtonList2.Text == "Round")
           {
               int x = Convert.ToInt32(rntotalprice.Text);
               int y = x + f;
               rntotalprice.Text = Convert.ToString(y);
           }

       }

推荐答案

1.您应该首先调试代码,然后按在与单选按钮链接的每个事件处理程序中放置断点。然后通过收音机来测试你的表格。

2.如果没有调用你的事件处理程序方法,这意味着你没有错误地将它们与你的控件链接:也许你不小心删除了链接,或者您与其他控件事件链接!
1.You should start by debugging your code, and by putting breakpoints in each event handler that are linked with your radio buttons. Then test your form by clinking on the radio.
2.If your event handler methods are not invoked, this means that you are not linked them incorrectly with your controls: maybe you accidentally delete the links, or you linked with other controls events!


这篇关于仅当下拉选择索引更改时,标签值才会更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆