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 7733395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:58:39+00:00 2026-06-01T06:58:39+00:00

I usually create a gridview based on data so it will have the rows

  • 0

I usually create a gridview based on data so it will have the rows depending on what the data source spits out but this time.. I need to do something different. I need to have 5 rows with the following on each row

TextBox |  DropDown   |   FileUploader  |  Checkbox
TextBox |  DropDown   |   FileUploader  |  Checkbox
TextBox |  DropDown   |   FileUploader  |  Checkbox
TextBox |  DropDown   |   FileUploader  |  Checkbox
TextBox |  DropDown   |   FileUploader  |  Checkbox

Then when a submit button is clicked it will take each row and create a product (I will call the Product class and just assign the properties the row and save the product as do the same for all rows).

How can i those 5 items to the gridview if its not dependant on data?, it will need to have the gridview properties like headers will be

Product Name  |  Lot #   |   Image   |     Active   

I am just not sure how to add those 5 rows if not depending on any data source, but still would like to use the gridview properties.

Any ideas would be much appreciated, first time i have to deal with the gridview not dependent on data.

NOTE: It will always be 5 rows.. no matter what and I will check if all the information is filled to decide whether to add the product or not.

Thank you

  • 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-01T06:58:40+00:00Added an answer on June 1, 2026 at 6:58 am

    First, let’s create the Gridview with controls in the markup, and a button underneath to save the products…

    <asp:GridView runat="server" ID="ProductGridview" AutoGenerateColumns="false">
        <Columns>
            <asp:TemplateField HeaderText="Product Name">
                <ItemTemplate>
                    <asp:TextBox runat="server" ID="ProductNameTextBox" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Lot #">
                <ItemTemplate>
                    <asp:DropDownList runat="server" ID="LotNumberDropDownList">
                        <asp:ListItem Text="1" />
                        <asp:ListItem Text="2" />
                        <asp:ListItem Text="3" />
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Image">
                <ItemTemplate>
                    <asp:FileUpload runat="server" ID="ImageFileUpload" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Active">
                <ItemTemplate>
                    <asp:CheckBox Text="Active" runat="server" ID="ActiveCheckBox" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:Button Text="Save Products" runat="server" ID="SaveProductsButton" OnClick="SaveProductsButton_Click" />
    

    … giving us a textbox, dropdownlist, fileupload and checkbox in each row.

    Now, we need to generate a set of 5 rows. We can do this really easily by binding the gridview to a List<int>, which we can generate in Page_Load…

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Generate a list of 5 integers - this will be the data source for the GridView
            List<int> rows = new List<int>();
    
            for (int i = 0; i < 5; i++)
            {
                rows.Add(i);
            }
    
            //Bind the Gridview to the list of integers so we get 5 rows in the UI
            ProductGridview.DataSource = rows;
            ProductGridview.DataBind();
        }
    }
    

    This gives us this as the rendered gridview:
    enter image description here

    Now we just need code to read the rows back in when the button is clicked; we iterate through the rows, locating the controls in each row to read their value…

    protected void SaveProductsButton_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in ProductGridview.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                // Have to cast the result of FindControl to the correct type
                TextBox productTextBox = (TextBox)row.FindControl("ProductNameTextBox");
                DropDownList lotNumberDropDownList = (DropDownList)row.FindControl("LotNumberDropDownList");
                FileUpload imageFileUpload = (FileUpload)row.FindControl("ImageFileUpload");
                CheckBox activeCheckBox = (CheckBox)row.FindControl("ActiveCheckBox");
    
                saveProduct(productTextBox.Text, lotNumberDropDownList.SelectedItem.Text,
                                       imageFileUpload.PostedFile, activeCheckBox.Checked);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I usually just create a datatable with one repeater and have all this html
Hey I usually run into a situation where I will create a class that
It seems dead simple, as to create an NSURLConnection I usually do this: NSURL
I usually create usercontrol which is referring javascript file/block. For example, I have a
I usually create the cscope database with the command, cscope -bqRv But at times,
I usually create a sequence from a single value using array syntax, like this:
I usually create ASP.NET websites and have a few classes I use, mainly a
I have a table with some columns. For archive purposes I usually create second
A lot of the time I will have a Business object that has a
I usually create a static class for my database calls. I have never used

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.