I'm developing a form that captures patient information. In the form, I
need the ability to add several insurance policies. The approach I have
decided to take is to load the separate insurance policies into a
multidimensional array. So:
// I create my array
string[,] arrInsurance = new string[5,15];
// During the AddButton_Click routine, I fill out my array with the current
data in the insurance form
arrInsurance[i,0] = "0" ;
arrInsurance[i,1] = "2" ;
arrInsurance[i,2] = strCompanyName ;
arrInsurance[i,3] = strStreetNbr ;
arrInsurance[i,4] = strStreetName ;
arrInsurance[i,5] = strCity ;
arrInsurance[i,6] = strState ;
arrInsurance[i,7] = strZip ;
arrInsurance[i,8] = strGroupNbr ;
arrInsurance[i,9] = strPolicyNbr ;
arrInsurance[i,10] = strClaimOrder ;
arrInsurance[i,11] = strPolicyType ;
arrInsurance[i,12] = strPolicyHolder ;
arrInsurance[i,13] = strSSN ;
arrInsurance[i,14] = strDOB ;
// But I need to save my array before I leave the AddButton_Click routine
into Viewstate, so I don't lose the data:
ViewState["ArrInsurance"] = arrInsurance. ;
This is about as far as I can get. The form lists the added insurance
policy, and allows the user to add another if they need to do so. The form
is reloaded and I lose my data. So I need to store the data in ViewState so
I can grab it back out of the array. The program bombs with some general
error, and I just can't figure this one out. Thank you in advance for
helping me with this.
While were at it, how do I get the array back from viewstate?