As I get all the Codes and Description from the database I am storing them in the List. But a few of the Descriptions have a second entry with the same Code to continue the Desciption that does not fit in the first entry field. So I add it to the Description and want to overwrite the List item. Just doing an Add does not do it. So I thought that if I find the index with IndexOf and do a RemoveAt and then do an Add again it would do it and it does not abort, but does not store anything.
Here is the code.
reasonList.IndexOf(myReason, indx);
reasonList.RemoveAt(indx);
reasonList.Add(new ReasonRecord(dataRowItem["Code"].ToString(), myReasonDesc));
myReasonDesc is the Description that adds the second Description to the first Description.
Say the first Description is "CLAIM WAS PAID UNDER THE NATIONAL PREFERRED" and
the second is " PROVIDER NETWORK". I now want to store the
"CLAIM WAS PAID UNDER THE NATIONAL PREFERRED PROVIDER NETWORK"
How can I do this?
Thanks for any help.
arep
Suthish NairPosted Oct 5, 2011, 2:27 PM
http://stackoverflow.com/questions/194852/concatenate-many-rows-into-a-single-text-string
A RepaskyPosted Oct 5, 2011, 12:00 PM
VulpesPosted Oct 5, 2011, 5:20 AM
I'd suggest the non-breaking space (Unicode 160) or (HTML) which shouldn't occur in ordinary text but looks like a space when displayed.
So you'd need to replace this line:
myReasonItem.Description += " " + dataRowItem["Description"];
with
myReasonItem.Description += " \xA0" + dataRowItem["Description"];
You can then recover the two parts with:
string[] items = myReasonItem.Description.Split('\xA0');
// items[0] is first part and items[1] is second part
A RepaskyPosted Oct 4, 2011, 10:07 PM
arep
VulpesPosted Oct 4, 2011, 6:14 PM
Javeed M ShaikhPosted Oct 4, 2011, 5:18 PM
You have a set of Rows with Duplicate Codes and also another set of record in List with Duplicate code. you want to merge the description from both these and create a new list with unique Codes and merged descriptions, is that correct?
A RepaskyPosted Oct 4, 2011, 4:58 PM
arep
A RepaskyPosted Oct 4, 2011, 4:52 PM
Javeed M ShaikhPosted Oct 4, 2011, 4:18 PM
reasonList.IndexOf(myReason, indx); --> Search for code from the index and below.
reasonList.RemoveAt(indx); --> Assuming the code is found and you remove that entry.
reasonList.Add(new ReasonRecord(dataRowItem["Code"].ToString(), myReasonDesc)); --> You add to the end of the list the code and the concatenated desc.
so is the last line not adding anything, please provide more code snippet to understand better.
Please do not forget to mark "Accepted Answer".