将多个值添加到单个索引 [英] Add multiple values to a single index
本文介绍了将多个值添加到单个索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将值添加到arraylist index [0]这里它是
I'm trying to add the value to arraylist index[0] here it is
DataTable dt5 = new DataTable();
dt5.Columns.Add("Data", typeof(string));
DataRow dr = dt5.NewRow();
ArrayList ary = new ArrayList();
foreach (Control ctr in dynamic.Controls)
{
if (ctr is TextBox)
{
string IDs = ((TextBox)ctr).ID;
string values = ((TextBox)ctr).Text;
string text= values;
ele = (new XElement(IDs, values));
ary.Insert(0, ele) ;
}
}
dr[0] = ary;
dt5.Rows.Add(dr);
这里ele对象获得结果为Xmlvalues< id> 75然后循环重复它得到其他价值< name> Usha
我想将这些值存储为单行,所以我试图在arraylist索引方法中执行它
但它存储索引数量,如索引[0],索引[1]。
所以我想存储这个多值在单行中并作为单个参数传递给我的存储过程
here the "ele" object gets the result as Xmlvalues <id>75 and next the loop repeats it get other value <name>Usha
I wanna store this values as single row so im trying to do it in arraylist index method
but it is storing in number of indexes like index[0],index[1].
So I wanna store this multi values in single row and pass as single parameter to my stored procedure
推荐答案
我得到了一个解决方案
StringBuilder sb = new StringBuilder();
sb.Append(ele);
var data = Convert.ToString(sb);
我可以将此var数据传递给我的存储过程
I got a solution for this
StringBuilder sb = new StringBuilder();
sb.Append(ele);
var data=Convert.ToString(sb);
And i can pass this var data to my Stored procedure
这篇关于将多个值添加到单个索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文