Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 .


C#
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 shows Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). error? in TaxFieldID what shall i do to resolve this probelm
Posted
Updated 12-May-19 5:31am
Comments
Richard MacCutchan 12-May-19 11:44am    
What is the definition of the TaxFieldID field?

You are trying to convert the ArrayList to Guid.
C#
TaxFieldID = new Guid(Alist .ToString ())

Use an iterator (for / while / foreach) to iterate through the ArrayList items and convert each item.
 
Share this answer
 
Comments
Member 12087373 8-Jan-16 2:49am    
I tried that also but i got object reference error it cannot get the object from viewmodel to controller
On the first look, below line may throw an error:
C#
TaxFieldID = new Guid(Alist .ToString ()),


Guid constructor does not accept array of strings, it accepts single string.
C#
Guid g = new Guid(Alist[0]);


See: Guid Constructor (System)[^]
 
Share this answer
 
Comments
Member 12087373 8-Jan-16 2:42am    
I need to save those six fields i that fields
Maciej Los 8-Jan-16 2:44am    
I need to see TaxInfoTaxFiled definition.
Member 12087373 8-Jan-16 2:48am    
yes sure It is a TaxInfoTaxfield Table . In that table i have 2 fields TaxFieldID and FieldValue . I need to save those six guid's in taxfieldID and ^ field values in Fieldvalue column
Maciej Los 8-Jan-16 2:55am    
None of above information is useful.
Member 12087373 8-Jan-16 3:00am    
hey i said my issue in one document clearly . shall i send that you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900