Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8779671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:51:13+00:00 2026-06-13T19:51:13+00:00

I have this GridView that I’m trying to bind data to and I need

  • 0

I have this GridView that I’m trying to bind data to and I need to create a new class with all my properties and display them in the Grid. Is this supposed to be a list collection because I tried a list but the Grid wasn’t able to find the names in the list.

I usually don’t deal with collections. So, I’m not very familiar with it. I just need some guidance on how this should be. I know I need a class for my collection and my properties are strings.

//This is where I am stuck, not sure how to set these and put these in a list.
public class Product
{
    string Title;
    string SmallImage;
}
<form id="ResultsForm" runat="server">
    <div id="SearchBox">
        <asp:TextBox ID="SearchBoxText" runat="server" Height="20px" Width="400px"></asp:TextBox>
        <asp:Button ID="SearchButton" runat="server" Height="30px" Width="100px" Text="Search" OnClick="SearchButton_Click" />
    </div>

    <div id="ResultsTable">
        <asp:GridView runat="server" ID="myGrid" 
                      OnRowCommand="MyGrid_RowCommand">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <img src='<%#Eval("SmallImage") %>' />
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField>
                    <ItemTemplate>
                        <div>Title: <%#Eval("Title") %>  </div>
                        <div>Weight: <%#Eval("Weight") %>  </div>
                        <asp:Button runat="server" ID="GetOfferButton" CommandArgument='<%#Eval("OfferID") %>'></asp:Button>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:51:15+00:00Added an answer on June 13, 2026 at 7:51 pm

    1) Create class in separate file… like Product.cs

     public class Product
        {
    
            public string Title { get; set; }
            public string SmallImage { get; set; }
        }
    

    2) In your aspx.cs

     protected void Page_Load(object sender, EventArgs e)
                {
    
                    if(!Page.IsPostBack)
                    {
                     List<Product> lst = new List<Product>();
                     lst.Add(new Product(){Title="title 1", SmallImage = "some path"});
                     lst.Add(new Product(){Title="title 2", SmallImage = "some "});
                     myGrid.DataSource = lst;
                     myGrid.DataBind();
                    }
    
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a GridView that bind to some data and it look like this:
i have an gridview that retrieves the data via a datatable like this: protected
I have a gridview that imports data from a remote database, this is working
I have a gridview that gets its data from a webservice. This comes into
I have a gridview that I'm trying to validate from code behind. In this
I have a gridview that contains one linkbutton within itemtemplate. I bind this gridview
I have this itemtemplate for a gridview column that is pulling data from a
I have a gridview that it bind to a data table.I want to add
I have a gridview data and this gridview have subgrid too. in the first
I have my <asp:GridView ID=gridView runat=server> I bind it like this : myConnection.Open(); SqlCommand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.