473,395 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Create a large grid with checkboxes?

Hi

I am not sure, what is the best way to do this, and I hope somebody can
offer some advice. :)

I have 30 brands (from one table) out of one axis and 30 product categories
(from another table) out another, and I have to register which brands have
what product categories (using checkboxes).

I have created a small image to help illustrate:
http://klausjensen.dk/images/checkgrid.gif

The user then checks some boxes and presses save, and I save the selections
to a third table.

What is the best and easiest way to create such a grid?

Thanks in advance

- Klaus

Jul 8 '07 #1
5 2309
"Klaus Jensen" <sp*********@fromcancer.comwrote in message
news:e7**************@TK2MSFTNGP04.phx.gbl...
What is the best and easiest way to create such a grid?
I don't think the actual creation of the grid per se is your problem...
Instead, I would imagine it's the creation of the DataSet to populate the
grid which will be the tricky bit...

Looks to me that what you have here is a requirement for a crosstab query.
How you achieve this will depend on the back-end RDBMS you're using:
http://www.google.co.uk/search?hl=en...+queries&meta=
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 8 '07 #2
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uE**************@TK2MSFTNGP06.phx.gbl...
Looks to me that what you have here is a requirement for a crosstab query.
How you achieve this will depend on the back-end RDBMS you're using:
http://www.google.co.uk/search?hl=en...+queries&meta=
Hi Mark

I am looking into pivot, the The Rozenshtein Method and other exciting stuff
now, thanks! :)

Jul 8 '07 #3
"Klaus Jensen" <sp*********@fromcancer.comwrote in message
news:eV**************@TK2MSFTNGP04.phx.gbl...
>Looks to me that what you have here is a requirement for a crosstab
query. How you achieve this will depend on the back-end RDBMS you're
using:
http://www.google.co.uk/search?hl=en...+queries&meta=
I am looking into pivot, the The Rozenshtein Method and other exciting
stuff now, thanks! :)
Ah, so I take it you're using SQL Server...?

If you need any further assistance with that, you'll probably get the
quickest and best response from microsoft.public.sqlserver.programming - the
guys over there live and breathe this sort of stuff... :-)
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 8 '07 #4
So Klaus, what did you end up doing? I have a similar situation and
would love to see samples of the ASP and query you came up with.

"Klaus Jensen" <sp*********@fromcancer.comwrote:
>"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uE**************@TK2MSFTNGP06.phx.gbl...
>Looks to me that what you have here is a requirement for a crosstab query.
How you achieve this will depend on the back-end RDBMS you're using:
http://www.google.co.uk/search?hl=en...+queries&meta=

Hi Mark

I am looking into pivot, the The Rozenshtein Method and other exciting stuff
now, thanks! :)
Jul 26 '07 #5
"BrentM" <br****@nospam.netwrote in message
news:9l********************************@4ax.com...
So Klaus, what did you end up doing? I have a similar situation and
would love to see samples of the ASP and query you came up with.
Hi Brent.

Sorry I did not see your post until now.

I ended up doing the work in the user-interface, no fance SQL. I created a
table (serverside), and then rendered the checkboxes manually. When I save,
I run through all cells in the table and save each cell seperately. It works
very fast, even though I am sure a more serverload-friendly solutiuon could
be deviced.

I have pasted the code below.

Sub RenderGrid()

Dim rw As TableRow
Dim cell As TableCell
Dim chkBox As CheckBox
Dim shopBrandProductCategoriesDataTable As DataTable =
DataAccess.ShopBrandProductCategory.GetForShop(_sh opId)
Dim brands As DataTable = GetBrands()
Dim productCategories As DataTable = GetProductCategories()
Dim rowNum As Integer = 0
Dim oddRow As Boolean = True
Dim oddCell As Boolean = True
Dim cssClass As String

'Render Grid
For Each brandRow As DataRow In brands.Rows

If rowNum Mod 5 = 0 Then
rw = New TableRow
rw.Cells.Add(New TableHeaderCell) 'Upper left cell left
blank...
rw.CssClass = "CheckboxGridHeader"

For Each productCategoryRow As DataRow In
productCategories.Rows
cell = New TableHeaderCell
cell.Text = productCategoryRow("ProductCategoryName")
rw.Cells.Add(cell)
Next
tblGrid.Rows.Add(rw)
End If

oddCell = True
If oddRow Then
cssClass = "CheckboxGridItem"
Else
cssClass = "CheckboxGridItemAlt"
End If

rw = New TableRow
rw.ID = "row_" & brandRow("BrandId")

rw.CssClass = cssClass & "2"

cell = New TableCell
cell.Text = brandRow("Brand")
rw.Cells.Add(cell)

For Each productCategoryRow As DataRow In productCategories.Rows
cell = New TableCell
cell.HorizontalAlign = HorizontalAlign.Center
If oddCell Then
cell.CssClass = cssClass & "1"
Else
cell.CssClass = cssClass & "2"
End If
chkBox = New CheckBox
chkBox.ID = "chk-" & brandRow("BrandId").ToString & "-" &
productCategoryRow("ProductCategoryId").ToString
If
ShopBrandProductCategories(shopBrandProductCategor iesDataTable,
brandRow("BrandId"), productCategoryRow("ProductCategoryId")) Then
chkBox.Checked = True

cell.Controls.Add(chkBox)
rw.Cells.Add(cell)
If oddCell Then oddCell = False Else oddCell = True
Next

tblGrid.Rows.Add(rw)

If oddRow Then oddRow = False Else oddRow = True
rowNum += 1
Next

End Sub

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click

Dim chkBox As CheckBox
Dim brandId, productCategoryId As Integer
Dim ids As String()

For Each row As TableRow In tblGrid.Rows
For Each cell As TableCell In row.Cells
For Each ctrl As Control In cell.Controls
If ctrl.ID.StartsWith("chk-") Then
chkBox = CType(ctrl, CheckBox)
ids = chkBox.ID.Split("-")
brandId = CType(ids(1), Integer)
productCategoryId = CType(ids(2), Integer)
If chkBox.Checked Then
DataAccess.ShopBrandProductCategory.Insert(_shopId ,
brandId, productCategoryId)
Else
DataAccess.ShopBrandProductCategory.Delete(_shopId ,
brandId, productCategoryId)
End If
End If
Next
Next
Next

End Sub

Aug 5 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tony Johansson | last post by:
Hello!! I need a product that could be used to create advanced grid. The requirement of the grid is the following: This grid has cells and in some cells not necessarilly a whole column but some...
1
by: Abhijit Salvi via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Abhijit Salvi Hi All, I am working on a DataGrid that has a column of Checkbox Controls. There is some Business Functionality...
2
by: Aadam | last post by:
Is there a grid that can contain comboboxes, checkboxes, etc. in the columns?
6
by: Sam | last post by:
Hi, I have a datagrid which has (amongst other stuff) 2 comboboxes columns. So far so good. The trick is that when I select a value in my first column, it must updates the items of the combobox in...
2
by: Questman | last post by:
Good afternoon, Does anyone have any code that implements, or approaches implementing, a cross-browser DHTML/JS solution to provide an Excel-like Grid on a web page - I'm trying to convert an...
3
by: Jordan | last post by:
Hey Peoples, I'm wonderg if there is a way to make a subclass of wx.grid.Grid in which the coloumn labels for the grid appear on the bottom of the grid instead of the top. 1 2 3 4 5 a| | ...
13
by: JJ | last post by:
I have a need to input a large tab delimited text file, which I will parse to check it has the expected columns, before allowing the user to submit it to the database. The user may paste the file...
2
by: yogeshtiwarijbp | last post by:
Hi All, Iam new in asp.net 2003 and sql server. I have to create an application having following criteria. Proposed Steps 1. Create a table containing fields as Name of Report, View Name or...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.