I am developing an asp.net application and I got stuck, so I am asking for some help.
Database: In my database (MySql) I have table ingredient(idI, name, etc.) and each ingredient can have more then one ingredient type(idT, type_name, etc.). Because of many to many relation I have another table which contains id from ingredient and id from ingredient type.
App: In my app I have gridview that shows all the data from ingredient. I use my own method called FillGVIngredient to fill gridview using dataset and data adapter.
Question: How can I display another column in my gridView which will show all the ingredient types that belongs to ingredient id (each row in gridview represents 1 ingredient) with bullet list so that the output will look like this:
Ingredient_Type Ingredient id
--------------------------------------
-type 1* ingredient1 1
-type 2*
-type 3*
--------------------------------------
-type 5 ingredient2 2
-type 6
*ingredient types must be displayed in single cell. Example above shows 2 rows from gridview.
I have tried using template field with bullet list but I don’t know how to iterate through rows so that I would pass the id of ingredient to sql statement of bullet list datasource.
You are on the right track. A BulletedList in a
TemplateFieldis the correct approach. But you should use GridView’s RowDataBound to bind it to it’sDataSource. Have a look: