473,511 Members | 16,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a data table w/ columns and rows

Jim
My subject probably isn't very descriptive of what I want to do, so
let me explain:

I wna tto have a website that holds a number of products, grouped by
category. On the administration page of the website, I want to allow
the operator to move products between categories. The interface I
have in mind would have two dropdowns at the top, one to select the
FROM categroy, which would cause the page to re-post, and thus display
all of the products in that catgegory. The second dropdown would
allow the operator to select the TO category where products would be
placed when they clicked the "Submit" button at the bottom.

Each prodcut has a name and an image. The images are stored on the
server, and their filenames are stored along with the item
descriptions in the database. What I would like for the page to do is
to display a grid, say thrww columns wide, and in each cell, show the
image, then the product name, and then a checkbox that would indicate
that this product is to be moved. For the time being, all the items
in the category can be displayed all at once, although eventually I'll
probably limit the number of rows in the table to 10-15, and then
provide links to the previous and next pages, to keep the page load
time down.

This sounds to me like something along the lines of what you'd do with
a datagrid control, but those usually repeat records one per row. In
this case, each row would have three records on it, as I stated above.
Each cell would then show the image, and then the product name below
it, and then a checkbox below that. Any suggestions as to how I might
lay out soemthing like this? I'm a little new to all these .NET
controls. Thanks!

JIM
Jul 21 '05 #1
3 1441
Cos
Jim,
You can get the kind of flexiblity you are looking for with creative use of the data grid. What you need to do is set up "template columns" in which each cell can contain multiple controls and you can control the layout like this:

<asp:TemplateColumn><ItemTemplate><asp:CheckBox id=CheckBox1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FileName") %>' Checked='<%# DataBinder.Eval(Container, "DataItem.Checked") %>'></asp:CheckBox><DIV align="right">(Pages:<asp:Label id=Label1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Pages") %>'></asp:Label>)</DIV></ItemTemplate></asp:TemplateColumn>

When your cells need contols with Event Handlers assigned dynamically, you can use the Item_DataBound Event in your code module as: (where the <i>second</i> control in the first cell is a dropdown box)

Private Sub myDG_ItemDatabound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dgProcedures.ItemDataBound

dim myDropDown as dropdownbox = directcast(e.item.cells(0).controls(1),dropdownbox )
addHandler myDropDown.SelectedIndexChange, addressof myDropDownHandler
'rem: the myDropDownHandler should not have a "handles" statement, but must have the same signature as the
' event hanldler

End Sub

I hope these point you in the right direction

Cos Callis, MCAD
Jul 21 '05 #2
Cos
Jim,
You can get the kind of flexiblity you are looking for with creative use of the data grid. What you need to do is set up "template columns" in which each cell can contain multiple controls and you can control the layout like this:

<asp:TemplateColumn><ItemTemplate><asp:CheckBox id=CheckBox1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FileName") %>' Checked='<%# DataBinder.Eval(Container, "DataItem.Checked") %>'></asp:CheckBox><DIV align="right">(Pages:<asp:Label id=Label1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Pages") %>'></asp:Label>)</DIV></ItemTemplate></asp:TemplateColumn>

When your cells need contols with Event Handlers assigned dynamically, you can use the Item_DataBound Event in your code module as: (where the <i>second</i> control in the first cell is a dropdown box)

Private Sub myDG_ItemDatabound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dgProcedures.ItemDataBound

dim myDropDown as dropdownbox = directcast(e.item.cells(0).controls(1),dropdownbox )
addHandler myDropDown.SelectedIndexChange, addressof myDropDownHandler
'rem: the myDropDownHandler should not have a "handles" statement, but must have the same signature as the
' event hanldler

End Sub

I hope these point you in the right direction

Cos Callis, MCAD
Jul 21 '05 #3

Hello!

I need the same functionality as Jim, however, I don't do Visual Basic.
Can you translate that VB sample code into C#, perchance?

Thanks so much,

Google Jenny

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #4

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

Similar topics

2
4420
by: ben moretti | last post by:
hi i'm learning python, and one area i'd use it for is data management in scientific computing. in the case i've tried i want to reformat a data file from a normalised list to a matrix with some...
9
11205
by: Lauren Quantrell | last post by:
Is there a way to create a text file (such as a Windows Notepad file) by using a trigger on a table? What I want to do is to send a row of information to a table where the table: tblFileData has...
7
9664
by: Wolfgang Kreuzer | last post by:
Hello all, I have two tables - Projects and ProjectStruct Table Projects contains master records of the projects, ProjectStruct allows to define a project herarchie and contains the fields...
2
4220
by: serge | last post by:
My project is to automate testing of Stored Procedures of type SELECT (at least for now). I want to create a table where each stored procedure's input parameter values are entered and in another...
4
1767
by: johnb41 | last post by:
I need to create a Dataset and datatable from an XML file. The only way I know how to make a Dataset and Datatable, is by using an Access database as my datastore: You know, the usual thing in...
1
3338
by: poohnie08 | last post by:
i have a excel spreadsheet showing staff name, date,work hour, ot hour, slot1, slot2, slot3, slot4 and others). The "()" will keep repeating from day 1 until end of month. eg in excel spreadsheet,...
9
3993
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
27
3741
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB...
1
3353
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
1
4872
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
0
7242
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
7423
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5668
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,...
1
5066
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.