|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
datacolumn replaceI have a datatable with two datacolumns as below Name(text) status(int) wws 0 ddd 1 ggg 0 hhh 0 cfff 1 Status datacolumn will have values either 0 or 1 only. I need to change the value 0 as "Pass" and 1 as "Fail". for changing the values i loop through each row and replace 0 as "Pass" and 1 as "Fail". for(int i=0;i<dataTable.rows.count;i++) { if(dataTable.Rows[i][1].ToString()==int.Parse("0")) { dataTable.Rows[i][1]="Pass"; } if(dataTable.Rows[i][1].ToString()==int.Parse("1")) { dataTable.Rows[i][1]="Fail"; } } I think above method takes more time,because it loops through each row and replace the value. Is there any way to replace all the values in the datacolumn simultaneously with out looping Regards, Mani Mani,
You can use the databinding events for this. However in this case I will probably just create an extra column with an expression. See this sample. http://www.vb-tips.com/default.aspx?ID=76a81eb8-ea2d-48f4-99c3-a3539697edbd I hope this helps, Cor Hi,
Thanks for your reply.Vb-Tops.com is very useful for me,but the links are not working. Regards, Mani |
|||||||||||||||||||||||