473,385 Members | 1,944 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,385 software developers and data experts.

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 1435
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
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
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
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
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
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
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
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
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
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
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.