Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I need to save those six fields in same column but not in same row and same cell. each field have default GUID.so i decided to put that default guid's in one list and fields in one list and call that object of that particular list where we want .
ArrayList Alist = new ArrayList();
Alist.Add("FD713788-B5AE-49FF-8B2C-F311B9CB0CC4");
Alist.Add("64B512E7-46AE-4989-A049-A446118099C4");
Alist.Add("376D45C8-659D-4ACE-B249-CFBF4F231915");
Alist.Add("59A2449A-C5C6-45B5-AA00-F535D83AD48B");
Alist.Add("03ADA903-D09A-4F53-8B67-7347A08EDAB1");
Alist.Add("2F405521-06A0-427C-B9A3-56B8931CFC57");
ArrayList objValue = new ArrayList();
objValue.Add(viewmodel.TinNo);
objValue.Add(viewmodel.CstNo);
objValue.Add(viewmodel.PanNo);
objValue.Add(viewmodel.CinNo);
objValue.Add(viewmodel.ExciseRegNo);
objValue.Add(viewmodel.ServiceTaxNo);
var TaxInfoTaxFiledclassobj = new TaxInfoTaxFiled()
TaxInfoTaxFieldID = TaxInfoTaxFieldObj,
TaxFieldID = new Guid(Alist .ToString ()),
FieldValue = objValue.ToString(),
All are working Fine
but in TaxFieldID it show the count which has been calculated from list but while saving it show the below error
What shall I do?
–
You're trying to pass an ArrayList
as a Guid. In this line:
TaxFieldID = Guid.Parse(Alist.ToString())
You need to select just one of the elements of the ArrayList
to parse. Additionally, you could use a List<Guid>
to eliminate the problem altogether.
List<Guid> guidList = new List<Guid>();
guidList.Add(new Guid("DDE4BA55-808E-479F-BE8B-72F69913442F"));
TaxFieldID = guidList[0]; // obviously, select the appropriate GUID
–
–
–
–
I guess you're looking for something like this -
var listFiled = new List<TaxInfoTaxFiled>();
for(var item = 0; item < objValue.Count ; item++)
listFiled.Add(new TaxInfoTaxFiled
TaxInfoTaxFieldID = TaxInfoTaxFieldObj,
TaxFieldID = new Guid(Alist[item]),
FieldValue = objValue[item]
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.