中继器的第三部分 [英] Part III of repeater

查看:103
本文介绍了中继器的第三部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在所有帮助下,我在您的帮助下解决了大部分问题.

我希望这是我需要帮助的最后一段代码.


使用中继器创建动态文本框时,我需要在每个新创建的文本框的相应文本框中放置百分比:


我第一个有这个

I have work out most of my problems with your help thanks to all assisted.

I hope this is the last piece of code I need help with.


With my repeater creating dynamic text boxes I need to place percentages in the appropriate text box per newly created textbox:


I have this for the first one

double amount = Convert.ToDouble(textBox.Text);
double subamount = Convert.ToDouble(textBox1.Text);
double per = (subamount  / amount) * 100;
percentage.text = per.ToString();


第一行的效果很好.

我重复了该过程


this work well for the first line.

I repeated the process

foreach (RepeaterItem item in Repeater1.Items)
{
string mbe = ((TextBox).item.FindControl("txtMBE")).Text;
if (mbe.ToString() == "Yes")
{
  string txtamount = ((TextBox)item.FindControl("txtAmount").Text;
  string txtmpercent = ((TextBox)item.FindControl("txtMPercent").Text;
  double dynamicamount = Convert.ToDouble();
  double dynamicsubamount = Convert.ToDouble();
  double dynamicpercent = (dynamicsubamount / dynamicamount) * 100;

My problem is how to write this to show in each newly created textbox where the txtMpercent appears 

}

}


当我建立和测试.我休息了一下,检查并进入代码中的这一点,它显示出它是在每个框上进行计算,而不是写入分配的文本框.

(顺便说一句,是/否是下拉列表)

我和我做错了.

其他使用字符串在我的应用程序中工作的计算机.


When I build and to test. I placed a break to check and stepping into I get to this point in the code it shows me that it is calculating on each box but not writing to the assigned textboxes.

(by the way the Yes/No are dropdownlist)

What and I doing wrong.

other using string to work in my application.

推荐答案

您具有:
double dynamicamount = Convert.ToDouble();
double dynamicsubamount = Convert.ToDouble();


您没有将任何值传递到Convert.ToDouble()中,所以这将是一个问题,不是吗?是这样编译的吗?

我认为您只需要将值分配回文本框即可:


You''re not passing any values into Convert.ToDouble(), so that would be a problem, no? Is it compiling like this?

I think you just have to assign the value back to the textbox:

((TextBox)item.FindControl("txtAmount").Text = your_value



干杯.



Cheers.


这篇关于中继器的第三部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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