Home   |   Asp.Net 2.0   |   .Net Framework 2.0   |   IIS 6.0   |   Sql Server 2005   |   Visual Basic 2005   |   c# 2005   |   VS 2005   |   Visual Source Safe 2005

MS Dynamics CRM 3.0

SharePoint Portal Server 2003
SharePoint Server 2007
Dynamics NAV
Dynamics CRM
SharePoint Designer 2007
SharePoint Portal Server 2001
Windows SharePoint Services
Windows SharePoint Services 3.0
Project Server 2003
Project Server 2007
Dynamics – Point of Sale
Dynamics AX
Dynamics GP
Dynamics Retail Management System (RMS)
Dynamics SL
SQL Server 2000
Visual Basic .NET 2003
Visual C# .NET 2003
Visual C++ .NET 2003
Visual C++ 2005
Visual SourceSafe 6.0
Windows Server 2003
Windows Server 2003
Outlook 2003
ADO.NET 1.1
ASP.NET 1.0
Visual Studio Team Foundation Server
Visual Studio 2005 Team Edition
Windows Internet Explorer 7
BizTalk Server 2000
BizTalk Server 2002
BizTalk Server 2004
BizTalk Server 2006
Visual Studio 6.0
Access 2000
Access 2002
Access 2003
Access 2007
Access 97
Collaboration Data Objects 2.0
Commerce Server 2002
Content Management Server 2001
Commerce Server 2007
Content Management Server 2002
Data Access Components 2.7
Data Access Components 2.8
DirectX 9.0b
Office Small Business Accounting 2006
Accounting 2007
ActiveSync 4.1
Class Server 2.0
Groove 2007
Windows Vista
Outlook 2007
OneNote 2003
OneNote 2007
Office X for Mac
Zune software
Zune Live
Zoo Tycoon 2
Flight Simulator 2002
Dungeon Siege II

Cervo Technologies
The Right Source to Outsource

Oracle Database FAQS

Sharepoint Portal Server KB

Outlook 2007 Knowledge Base Articles

ASP.NET 2.0 Knowledge Base Articles

Error message when you try to run an ASP.NET 2.0 Web application: An unhandled exception occurred during the execution of the current web request


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.

CAUSE

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.
<asp:HyperLink ID="HyperLink1"
    NavigateUrl='<%# Eval("au_fname", "http://{0}/{1}/{2}") %>' runat="server" Text='<%# Eval("au_fname", "go/{0}") %>'>
</asp:HyperLink>
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.

RESOLUTION

To resolve this problem, use the following code to replace the code that is generated by Visual Web Developer.
<asp:HyperLink ID="HyperLink1"
    NavigateUrl='<%# String.Format("http://{0}/{1}/{2}", DataBinder.Eval(Container.DataItem,"au_fname"),
    DataBinder.Eval(Container.DataItem,"au_lname"),DataBinder.Eval(Container.DataItem,"au_id")) %>' runat="server">
</asp:HyperLink>
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.

MORE INFORMATION

Steps to reproduce this problem

1.Start Visual Web Developer.
2.Create a new ASP.NET Web site. To do this, follow these steps:
a. In the File menu, click New Web Site.
b. 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.
3.Replace the code in the Default.aspx file by using the following code.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:GridView AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="au_id"
            DataSourceID="SqlDataSource2" ID="GridView1" PageSize="4" runat="server" AllowSorting="True">
            <Columns>
                <asp:BoundField DataField="au_id" HeaderText="au_id" ReadOnly="True" SortExpression="au_id" AccessibleHeaderText="sample">
                </asp:BoundField>
                <asp:BoundField DataField="au_lname" HeaderText="au_lname" SortExpression="au_lname">
                </asp:BoundField>
                <asp:BoundField DataField="au_fname" HeaderText="au_fname" SortExpression="au_fname">
                </asp:BoundField>
                <asp:BoundField DataField="phone" HeaderText="phone" SortExpression="phone"></asp:BoundField>
                <asp:HyperLinkField DataNavigateUrlFields="au_fname,au_lname,au_id" DataNavigateUrlFormatString="http://{0}/{1}/{2}"
                    DataTextField="au_fname" DataTextFormatString="Name: {0}" HeaderText="The Link"
                    SortExpression="au_fname"></asp:HyperLinkField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ConnectionString="data source=myDataSource;initial catalog=pubs;user=myUserName;pwd=myPassword"
            ID="SqlDataSource2" runat="server" SelectCommand="SELECT * FROM authors" CacheExpirationPolicy="Sliding" UpdateCommand="update test set &#13;&#10;path=@path, &#13;&#10;name=@name &#13;&#10;where id1=@id1" OldValuesParameterFormatString="{0}"></asp:SqlDataSource>
    </form>
</body>
</html>
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.
4.Click Design to switch to Design view, and then click the GridView control.
5.Click the smart tag icon to open the GridView Tasks menu, and then click Edit Columns.
6.In the Fields dialog box, click The Link in the Selected Fields list, and then click Convert this field into a TemplateField.
7.Click OK.
8.In the Debug menu, click Start Debugging.


APPLIES TO
Microsoft ASP.NET 2.0

Keywords: 
kbasp kbconversion kbtshoot kbprb KB916443

Copyright © 2004 - 2007 Gridview.org, Inc. All rights reserved. Powered by Smart Web Content Management System