title: Input string was not in a correct format in rowcommand
body: <p>I have a gridview wherein all the controls are in a single templatefield as below:</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" GridLines="None" AutoGenerateColumns="False" BorderWidth="1px" BorderColor="#CCCCCC" DataKeyNames="RegistrationId" Width="476px" DataSourceID="SqlDataSource1" ShowHeader="False" AllowPaging="True" CssClass="auto-style89" OnRowCommand="GridView1_RowCommand"&gt;
                  &lt;Columns&gt;
                      &lt;asp:TemplateField&gt;
                          &lt;ItemTemplate&gt;
                              &lt;table cellpadding="0" cellspacing="0" class="auto-style4"&gt;
                                  &lt;tr&gt;
                                      &lt;td class="auto-style56" style="vertical-align:top" rowspan="3"&gt;
                                          &lt;asp:Image ID="Image1" runat="server" Width="100px" Height="100px" ImageUrl='&lt;%# Bind("LogoPath") %&gt;' style="border: 3px groove #666666; padding: 2px;" /&gt;
                                      &lt;/td&gt;
                                      &lt;td colspan="2" style="background-color: #B22222"&gt;
                                          &amp;nbsp;
                                          &lt;asp:Label ID="lblBusinessName" runat="server" style="font-size: large; color: #FFFFFF; font-weight: 700;" Text='&lt;%# Bind("BusinessName") %&gt;'&gt;&lt;/asp:Label&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td class="auto-style81"&gt;
                                          &amp;nbsp;&lt;asp:Label ID="lblAddress" runat="server" Text='&lt;%# Bind("StreetAddress") %&gt;' style="color: #6699FF; font-size: small;"&gt;&lt;/asp:Label&gt;
                                          &amp;nbsp;|
                                          &lt;asp:Label ID="lblCity" runat="server" Text='&lt;%# Bind("City") %&gt;' style="color: #6699FF; font-size: small;"&gt;&lt;/asp:Label&gt;
                                          &amp;nbsp;-
                                          &lt;asp:Label ID="lblZipCode" runat="server" Text='&lt;%# Bind("ZipCode") %&gt;' style="color: #6699FF; font-size: small;"&gt;&lt;/asp:Label&gt;
                                          &amp;nbsp;|
                                          &lt;asp:Label ID="lblStates" runat="server" Text='&lt;%# Bind("States") %&gt;' style="color: #6699FF; font-size: small;"&gt;&lt;/asp:Label&gt;
                                          &amp;nbsp;&lt;/td&gt;
                                      &lt;td class="auto-style82"&gt;
                                          &lt;asp:Button ID="btnMore" runat="server" CommandName="Select" BackColor="#3366FF" ForeColor="White" Text="More Info" style="border-style: groove; border-color: #666666; padding: 2px; background-color: #808080; font-weight: 700;" /&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td class="auto-style17"&gt;&amp;nbsp;&lt;span class="auto-style57"&gt;Phone No&lt;/span&gt;:
                                          &lt;asp:Label ID="lblContactNo" runat="server" Text='&lt;%# Bind("ContactNo") %&gt;' style="font-size: small"&gt;&lt;/asp:Label&gt;
                                          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;span class="auto-style57"&gt;Website&lt;/span&gt;:
                                          &lt;asp:Label ID="lblWebsite" runat="server" Text='&lt;%# Bind("Website") %&gt;' style="font-size: small"&gt;&lt;/asp:Label&gt;
                                      &lt;/td&gt;
                                      &lt;td style="text-align: center" class="auto-style18"&gt;&lt;span class="auto-style57"&gt;&lt;strong&gt;Reviews&lt;/strong&gt;&lt;/span&gt;(0)&lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;/table&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                  &lt;/Columns&gt;
              &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Here is the code-behind:</p>
  
  <pre><code> protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  {
      if(e.CommandName=="Select")
      {
          int index = Convert.ToInt32(e.CommandArgument);
          GridViewRow selectedRow = GridView1.Rows[index];
          //string BusinessName = selectedRow.FindControl("lblBusinessName").ToString();
          //Session["BusinessName"] = BusinessName;
      }
  }
  </code></pre>
  
  <p>I get the error on the line below:</p>
  
  <pre><code>   int index = Convert.ToInt32(e.CommandArgument);
  </code></pre>
  
  <p>What seems to be the problem here? Is it because i am using a button instead of a buttonfield.I am just guessing though.I know that the commandarguement is null but how do i correct it?</p>