for (int i=1; i<=10; i++) { if (((TextBox)(this.Page.Controls.FindControl("Textbox"+i.ToString())).Text == String.Empty) ((TextBox)(this.Page.Controls.FindControl("Textbox"+i.ToString())).Text == "0.00" }
怎么都用C#呀!我的是VB.net语言
For Each c As Control In Me.Page.Controls(1).Controls If TypeOf c Is TextBox Then If CType(c, TextBox).Text = "" Then CType(c, TextBox).Text = "0.00" End If End If Next
For Each c As Control In Me.Page.Controls(1).Controls If TypeOf c Is TextBox Then If CType(c, TextBox).Text = "" Then CType(c, TextBox).Text = "0.00" End If End If Next 好象不对吧
估计还是的foreach 找出来,判断是否为空
foreach(Control c in this.Page.Controls[1].Controls)
{
if(c is TextBox)
{
((TextBox)c).Text="0.00";
}}
for (int i=1; i<=10; i++)
{
if (((TextBox)(this.Page.Controls.FindControl("Textbox"+i.ToString())).Text == String.Empty)
((TextBox)(this.Page.Controls.FindControl("Textbox"+i.ToString())).Text == "0.00"
}
这个网页可以自由转换vb-c#自己去试试..不过有些可能还是要改的比如()[]
{
if (((TextBox)(this.Page.Controls.FindControl("Textbox"+i.ToString())).Text == String.Empty)
((TextBox)(this.Page.Controls.FindControl("Textbox"+i.ToString())).Text == "0.00"
}
If TypeOf c Is TextBox Then
If CType(c, TextBox).Text = "" Then
CType(c, TextBox).Text = "0.00"
End If
End If
Next
If TypeOf c Is TextBox Then
If CType(c, TextBox).Text = "" Then
CType(c, TextBox).Text = "0.00"
End If
End If
Next
好象不对吧