I am successfully retrieving all the records I need from my database, however only one record is getting displayed in my `GridView`. 

I've been trying to solve this for the past couple of days, and I am really getting frustrated since I ran out of options to try. I am desperately in need of some help.

I've tried to manipulate the query because I originally thought that it was the problem, tried to convert the data I retrieve from `IQueryable` to `List<MyObject>()`, tried to add `.Cast<object>().ToList();` at the end of the `GridView.DataSource`, and even tried the use of `ViewState`s, and much much more!

Please, anyone, help.

I do have `onRowDataBound` and on `selectedIndexChanged` events for the `GridView` because I read that they can cause this issue.

Below is my code: 

**GridView**: 

```
gvSubCategories.DataSource = new BASubCategory().GetSubCatWithCatName();
gvSubCategories.DataBind();

protected void gvSubCategories_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        SubCategory currentSubCat = (SubCategory)e.Row.DataItem;

        //Image img = (Image)e.Row.FindControl("imgSubCategory");
        //img.ImageUrl = currentSubCat.ImageURL;
    }
}

protected void gvSubCategories_SelectedIndexChanged(object sender, EventArgs e)
{
    BASubCategory baSubCat = new BASubCategory();
    Guid id = new Guid(gvSubCategories.SelectedDataKey.Value.ToString());
    SubCategory subCat = baSubCat.GetSubCategory(id);

    txtName.Text = subCat.Name;
    imgImage.ImageUrl = subCat.ImageURL;
}

```

**GridView Definition**

```
<div class="content">

    <asp:GridView ID="gvSubCategories" runat="server" DataKeyNames="ID" AutoGenerateColumns="false"
        onrowdatabound="gvSubCategories_RowDataBound" 
        onselectedindexchanged="gvSubCategories_SelectedIndexChanged">
        <Columns>
            <asp:CommandField ShowSelectButton="true" />
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Image ID="imgSubCategory" runat="server" Width="100px" Height="100px" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="CategoryName" HeaderText="Category Name" />
            <asp:BoundField DataField="SubCategoryName" HeaderText="Sub Category Name" />
            <asp:BoundField DataField="SubCategoryImage" HeaderText="Sub Category Image" />
        </Columns>
    </asp:GridView>

</div>

```