Solved

Dynamic table

Posted on 2004-09-29
6
173 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
ID: 12187589
ASP.NET or Windows Form???
0
 

Author Comment

by:narenonline2k
ID: 12228223
It is for Windows Form
0
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 250 total points
ID: 12234223
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

930 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

21 Experts available now in Live!

Get 1:1 Help Now