Getting error when deleting row from GridView
<p>My ASPX code is:</p>

<pre><code>&lt;asp:gridview ID="Gridview1" runat="server" ShowFooter="true" 
                                    AutoGenerateColumns="false" OnRowDeleting="Gridview1_RowDeleting" AutoGenerateDeleteButton="true"&gt;
        &lt;Columns&gt;


        &lt;asp:BoundField DataField="RowNumber" HeaderText="Row Number" /&gt;
        &lt;asp:TemplateField HeaderText="Column Name"&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;

     &lt;%-- &lt;asp:TemplateField HeaderText="Header 2"&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:TextBox ID="TextBox2" runat="server"&gt;&lt;/asp:TextBox&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;--%&gt;
        &lt;asp:TemplateField HeaderText="Data Type"&gt;
            &lt;ItemTemplate&gt;
                  &lt;asp:DropDownList ID="ddldatatype" runat="server"&gt;
                  &lt;asp:ListItem&gt;varchar&lt;/asp:ListItem&gt;
                  &lt;asp:ListItem&gt;int&lt;/asp:ListItem&gt;
                  &lt;asp:ListItem&gt;numeric&lt;/asp:ListItem&gt;
                  &lt;asp:ListItem&gt;uniqueidentifier&lt;/asp:ListItem&gt;
                  &lt;asp:ListItem&gt;char&lt;/asp:ListItem&gt;
                  &lt;/asp:DropDownList&gt;
            &lt;/ItemTemplate&gt;
            &lt;FooterStyle HorizontalAlign="Right" /&gt;
            &lt;FooterTemplate&gt;
            &lt;asp:Button ID="ButtonAdd" runat="server" Text="Add New Row" OnClick="ButtonAdd_Click"/&gt;
             &lt;asp:Button ID="ButtonDel" runat="server" Text="Delete Row" OnClick="ButtonDel_Click" /&gt;
             &lt;input type="hidden" runat="server" value="0" id="hiddencount" /&gt;
            &lt;/FooterTemplate&gt;
        &lt;/asp:TemplateField&gt;
        &lt;asp:TemplateField&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:LinkButton ID="lnkdelete" runat="server" &gt;Delete&lt;/asp:LinkButton&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
        &lt;/Columns&gt;
&lt;/asp:gridview&gt;
</code></pre>

<p>and my C# code is:</p>

<pre><code> protected void Gridview1_RowDeleting(object sender, GridViewDeleteEventArgs e)
     {

         Gridview1.DeleteRow((int)Gridview1.DataKeys[e.RowIndex].Value);
         Gridview1.DataBind();


     }
 if (!IsPostBack)
        {
            Gridview1.DataSource = dt;
            Gridview1.DataBind();
        }
</code></pre>

<p>I am getting the error:</p>

<blockquote>
  <p>Index was out of range. Must be non-negative and less than the size of
  the collection. Parameter name: index</p>
</blockquote>
