Grid of checkboxes to display....

bizzydint

Regular
Joined
Apr 8, 2003
Messages
75
Has anyone got any ideas on how I can create the following display...?

(NB: am giving an example of the data being displayed...)

It's a simple 2 dimensional grid, with book names along the left and book shop names along the top. Then each cell in the grid contains a checkbox which is ticked if the book is supplied by that shop. (many books to many shops!)

To top it all off, the book names and shops names need to be pulled out of a database and therefore the display needs to be dynamically created.


I'm currently playing around with the datagrid control but it's looking tricky and i was wondering if anyone knows of a better way forward??


Cheers all.
Van
 
Write dynamic a HTML-Table!

C#:
HtmlTable tbl = new HtmlTable();
			
//Create HeaderCell
HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell td = new HtmlTableCell(); //empty (top-left cell)
tr.Cells.Add(td);
foreach (DataRow ShopRow in Shops.Rows)
{
	td = new HtmlTableCell();
	td.InnerText = ShopRow["Shopname"].ToString();
}
tbl.Rows.Add(tr);
			
//Books are written from top to bottom...
foreach (DataRow BookRow in Books.Rows)
{
	tr = new HtmlTableRow();

	td = new HtmlTableCell();
	td.InnerText = BookRow["Bookname"].ToString();
	tr.Cells.Add(td);

	//Shops are written from left to right...
	foreach (DataRow ShopRow in Shops.Rows)
	{
		td = new HtmlTableCell();
		CheckBox cb = new CheckBox();
		td.Controls.Add(cb);
					
		tr.Cells.Add(td);
	}

	tbl.Rows.Add(tr);
}

Page.Controls.Add(tbl);
 
Last edited by a moderator:
cheers for the help! I've stuck to the slightly more complex dynamic datagrid because it gives me more flexibility - but I might try this one out later when i have a bit more time on my hands...

so thanks :)
 
Back
Top