System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
<p>I am Getting this error
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index</p>

<p>Source Error:</p>

<blockquote>
  <p>Line 153:         Session["Cat"] = e.CommandArgument.ToString();<br>
  Line 154:<br>
  Line 155:         Session["Cat_ID"] =
  DataList3.DataKeys[e.Item.ItemIndex].ToString();//error<br>
  Line 156:     Response.Redirect("Disp_Category.aspx?id=C"); 
  Line 157:     }</p>
</blockquote>

<p>Please some one what is wrong with this code</p>

<pre><code>protected void DataList3_ItemCommand(object source, DataListCommandEventArgs e)
 {
     Session["L_Id"] = ddlLanguage.SelectedValue;
     Session["Cat"] = e.CommandArgument.ToString();

     Session["Cat_ID"] = DataList3.DataKeys[e.Item.ItemIndex].ToString();
     Response.Redirect("Disp_Category.aspx?id=C");
 }
</code></pre>

<p>on aspx file i have this </p>

<pre><code>&lt;asp:DataList ID="DataList3" runat="server" DataKeyNames="C_Id" DataSourceID="SqlDataSource3" OnItemCommand="DataList3_ItemCommand"&gt;
                                &lt;ItemTemplate&gt;
                                    &lt;table cellpadding="0" cellspacing="0" border=1 width=150&gt;
                                        &lt;tr&gt;
                                            &lt;td&gt;
                                                &lt;asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='&lt;%# Eval("C_Name") %&gt;'
                                                    Text='&lt;%# Eval("C_Name") %&gt;' CausesValidation="False"&gt;&lt;/asp:LinkButton&gt;&lt;/td&gt;
                                        &lt;/tr&gt;
                                    &lt;/table&gt;
                                &lt;/ItemTemplate&gt;
                            &lt;/asp:DataList&gt;&lt;asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=D:\New Projects\Sym\App_Data\Music.mdf;Integrated Security=True;User Instance=True"
                                ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [Category] ORDER BY [C_Name]"&gt;
                            &lt;/asp:SqlDataSource&gt;
</code></pre>