Link to home
Start Free TrialLog in
Avatar of blueskybooking
blueskybookingFlag for Canada

asked on

ASP.NET : Setting up a custom table with checkboxes

I found the GridView to be limiting for my needs and instead I want to use a table.

I am having issues with how checkboxes and tables are managed.

My issues are:

  o Adding multiple checkboxes with unique values, of which I may have disabled
     checkboxes depending on my data

     HTML Example: <input type="checkbox" value="1">

  o Adding rows vertically, this appears to be adding them horizontally
Dim lstCustomers As New CheckBox
Dim intID As Integer
Dim strName As String

Dim r As New TableRow()
Dim c As New TableCell()

' How to assign intID to lstCustomers checkbox?
intID = 1
strName = "John Smith"

c.Controls.Add(lstCustomers)
r.Cells.Add(c)
c.Controls.Add(New LiteralControl(strName))
r.Cells.Add(c)
tblCustomers.Rows.Add(r)

' How to assign intID to lstCustomers checkbox?
intID = 2
strName = "Bob Smith"

c.Controls.Add(lstCustomers)
r.Cells.Add(c)
c.Controls.Add(New LiteralControl(strName))
r.Cells.Add(c)
tblCustomers.Rows.Add(r)

Open in new window

<asp:Table ID="tblCustomers" BorderWidth="1" GridLines="Both" runat="server" />

Open in new window

TableControl.png
Avatar of Rouchie
Rouchie
Flag of United Kingdom of Great Britain and Northern Ireland image

Could you please clarify what you are trying to achieve here?  e.g. the purpose of your page and what you are doing with the data?

The reason for asking is that the gridview is actually more than capable of achieving most tasks like this, but if there's a trick that you're missing that can make it easier for you, then we can identify it based on what you need to do.
Avatar of blueskybooking

ASKER

I have checkboxes displaying or not displaying depending on related columns.  Some rows are completely disabled including disabled checkboxes and buttons.  From what I had seen, this was beyond what Gridview could readily manage without a lot of background code.  My thinking was that a table would be easier to manage, but perhaps not.

Here's an example of my design and run time.  It'll probably get a little more complicated than this when all is said and done, but this should cover off most of the issues.
TableDesigntime.png
TableRuntime.png
Its actually very easy in the gridview, but yes, you do need code to make it work.  However, that's actually a good thing when you've done it because you have TONS more control over how things work.

I can show you some code to get it working, which you can tweak, but first can I ask about the functionality of the CHANGE button on each row?  What does that do when pressed?  The reason is that the Gridview can optionally show values, then switch them to editable fields when Change is pressed.  Or, it can just present editable values that can be saved when Change is pressed.

Just let me know...
Here a better overview of the functions.  The idea is to have my system contact people via phone or email depending on what the user selects.  There will be defaults which will automatically be checked.  The flow doesn't make much sense yet as I still have design to complete, but if I am able to work the programming side of it I can massage the flow later.

  o Auto-select all columns (1st column and Email), preferably in JavaScript so the
     page does not refresh.  I've seen code for this but it's appears a little more difficult
     in a Gridview.

  o I need to extract the underlying table ID details based on the 1st column checkbox.

  o Send allows customer to update/send via another page, a "Sending" page.  Send Selected
     will post updates all the items selected in the first column in this "Sending" page.

  o Edit will direct to another page with the table ID of the row.

  o The "Sending" page will need the ID numbers passed through as well.

  o Some columns will be "grayed out", I have used strike through for this example.
     Note the buttons and drop-downs are disabled for that line as well.
TableControl.png
ASKER CERTIFIED SOLUTION
Avatar of Rouchie
Rouchie
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for the details.  I am reviewing your solution and will update you shortly.
Take your time - there is a lot to take in (but I promise it's worth the effort...!)  :-)
Your solution was complete.  And while it looks like I can get everything in, it looks like my requirements and how I have things structured may be easier to do in a custom table.  Thank you for your insights.