I have a page with a nested Gridview where I’m trying to fill the inner grid by pulling a string value from each line of the outer grid. When I try to pass the value from the outer grid to the string variable I get the “Error when converting ‘String’ to ‘System.IFormatProvider'” error. I’m using the following code to store the gridview cell value to the variable:
Dim Svc_Name As String = grdOuterGridView.DataKeyNames(e.Row.RowIndex).ToString("THIRD_PARTY_SERVICE")
Can anyone tell me what I’m doing wrong here? Thanks.
The DataKeysNames is already an array of string, you don’t need the ToString(….) part.
Actually your error comes from the ToString(“THIRD_PARTY_SERVICE”). The ToString() override that takes one parameter requires an object that implements
IFormatProviderinterface, but of course a string doesn’t have this interface, thus the error. However, calling ToString() on a String has no effect as you can read from the MSDN docs