将控件ID与迭代变量合并 [英] Concatinate control id with iteration variable
本文介绍了将控件ID与迭代变量合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的人们,
请帮帮我...
我有5个服务器隐藏字段控件,即..
hdnDc1
hdnDc2
hdnDc3
hdnDc4
hdnDc5
如何通过for循环访问这些值..
我正在尝试,但不会
Dear Folks,
Please help me...
i have 5 server hidden field controls namely..
hdnDc1
hdnDc2
hdnDc3
hdnDc4
hdnDc5
how to those values through for loop..
im trying this, but it won''t
for(int i=0;i<=5;i++)
{
string test = hdnDc + i;
}
请回答我..
有可能...吗?
谢谢&问候,
Kanag.M
Please Answer me..
is it possible... ?
Thanks & Regards,
Kanag.M
推荐答案
我认为您应该将所有值存储在一个数组中,然后通过for循环访问它.
上面的代码有什么错误!请解释一下!
I think u should have to store all values in one array and acess then to it via for loop.
And what is your error in above code!plz explain!
尝试下面的代码:-
测试数组变量获取所有服务器名称..
和test2变量在单个变量中获取名称...
try below code:-
test array variable gets all the server names..
and test2 variable get names in single variable...
string[] test=new string[5];
string test2="";
for (int i = 0; i < 5; i++)
{
test[i]="hdnDc"+i; //take it in array or
test2 = test2 + " hdnDc" + i; // Concate in single variable
}
请在此处添加您的解决方案,因此,如果其他任何问题遇到相同的问题,则可以快速解决.
Please add your solution here,so if any other get same problem then it will be solved fast.
这篇关于将控件ID与迭代变量合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文