This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
When you try to run a Microsoft ASP.NET 2.0 Web application that is built on the Microsoft .NET Framework 2.0, you receive the following error message:
Index (zero based) must be greater than or equal to zero and less than the size of the argument list. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
This problem occurs when you try to convert a hyperlink field by clicking the Convert this field into a TemplateField link in the Fields dialog box in Microsoft Visual Web Developer.
This problem is caused by incorrect code that is generated by Visual Web Developer. When you click the Convert this field into a TemplateField link in the Fields dialog box, code that resembles the following is generated.
Note HyperLink1 is a placeholder for the name of the Hyperlink control. au_fname is a placeholder for name of the data source field that contains "first name" information. You must change these names to match your application.
To resolve this problem, use the following code to replace the code that is generated by Visual Web Developer.
Note HyperLink1 is a placeholder for the name of the Hyperlink control. au_lname is a placeholder for name of the data source field that contains "last name" information. You must change these names to match your application.
Steps to reproduce this problem
Start Visual Web Developer.
Create a new ASP.NET Web site. To do this, follow these steps:
In the File menu, click New Web Site.
In the New Web Site dialog box, click ASP.NET Web Site, and then click OK.
Note A new Web site project is created. The Default.aspx file is opened in the Source view.
Replace the code in the Default.aspx file by using the following code.
Note Change the data source connection information in this code to match your data source. In this code, myDataSource is a placeholder for the name of the data source, myUserName is a placeholder for the user name that is used to connect to the data source, and myPassword is a placeholder for a password.
Click Design to switch to Design view, and then click the GridView control.
Click the smart tag icon to open the GridView Tasks menu, and then click Edit Columns.
In the Fields dialog box, click The Link in the Selected Fields list, and then click Convert this field into a TemplateField.