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
First, let’s create the Gridview with controls in the markup, and a button underneath to save the products…
… 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 inPage_Load…This gives us this as the rendered gridview:

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…