开发者

dataview rowfilter in Loop

开发者 https://www.devze.com 2023-03-25 21:53 出处:网络
DataTable Table = new DataTable(); DataRow row; try { row = Value.NewRow(); for (int i = 0; i < Value.Rows.Count; i++)
        DataTable Table = new DataTable();
        DataRow row;
        try
        {
            row = Value.NewRow();
            for (int i = 0; i < Value.Rows.Count; i++)
            {
                TableNm = new DataView(DB.Tables[1]);
                TableNm.RowFilter = "name = " + "'" +""+Value.Rows[i][0].ToString()+"" + "'" + "";
                row[i] = (TableNm.ToTable()).Rows;
            }开发者_如何学Python
            Table.Rows.Add(row);

For The Above I am Trying to Filter Multiple value and Bind or add row in data table But it's not working any suggestion for dataview rowfilter in for loop where every Rowfilter return only one row every time


It's a real problem you can add Dynamically column first than try row.add(row item arry) instant of row.add()

just like

 DataTable Table = new DataTable();
    DataRow row;
    try
    {
//Add column here

        row = Value.NewRow();
        for (int i = 0; i < Value.Rows.Count; i++)
        {
            TableNm = new DataView(DB.Tables[1]);
            TableNm.RowFilter = "name = " + "'" +""+Value.Rows[i][0].ToString()+"" + "'" + "";
            row[i] = (TableNm.ToTable()).Rows;
        }
        Table.Rows.Add(row.ItemArray);
0

精彩评论

暂无评论...
验证码 换一张
取 消