Solved

Dynamic table

Posted on 2004-09-29
6
172 Views
Last Modified: 2010-04-23
I have the following requirement:
Step 1: User clicks a "button" to launch a form that asks the number of rows & columns s/he wants. S/he enters the number of rows & columns and hits "Next"
Step 2: In the next window a table with the number of rows & columns appears. User enters some value and submits it to a SQL Server database
------
Step 3: These values of the rows & columns are later retrieved from the database and displayed as a table in a browser using XML & XSLT
------

Question: I am familiar with Step 3, but not sure how to proceed with developing the dynamic table wizard. I presume we must use Datagrid. Any inputs will make my day :)

Regards,
Naren
0
Comment
Question by:narenonline2k
  • 2
6 Comments
 
LVL 19

Expert Comment

by:arif_eqbal
Comment Utility
ASP.NET or Windows Form???
0
 

Author Comment

by:narenonline2k
Comment Utility
It is for Windows Form
0
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 250 total points
Comment Utility
You surely have to use DataGrid....
Say the user enters R rows C Cols then on NEXT Click:

Dim DT As DataTable=New DataTable()
Dim i as Integer

'Create the Columns for the Table
For i=0 to C-1
DT.Columns.Add("Col" & Cstr(i), Type.GetType("System.String"))
Next

'Now this is assuming all Cols are String in case there are different dataTypes you'll have to devise a mechanism, may be the user will provide the dataTypes too

Then

DataGrid1.DataSource = DT

'This will show a Grid with appropriate number of Cols. Now as for the Rows it will only show One Row when the user clicks on it he goes into Edit mode and automatically a new row will also append. If this is OK then that is it otherwise you need to Add dummy Rows to the dataTable may be you can add blank Rows like.

Dim Dr As DataRow
Dr = DT.NewRow
Dr(0)=""
DT.Rows.Add(Dr)

You can put this also in a loop till the No of rows R




0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now