Hi All,
I have problem in manipulation data grid.
The datagrid contains dynamic number of columns, and there is possibilty of the datagrid to be longer than the browser's viewport.
Users/clients will need to scroll horizontally, This can make user to loss track of the other part of the datagrid. So am thinking of transposing the data grid, so that the user will b able to scroll vertically.

My Problem is

1. How can I transpose a datagrid (vertical scrolling)
or

2. I have a work around, i built a dynamic table to solved the problem, How?
I transposed the dataTable and loop thru it to capture the values of each field. Each field contains html controls, Dont know why, web controls are not showing, They are all run at server. The string builder hold the html scripts to build the table.

my problem is how I capturing data from the controls....


Below is d code i used in creating the dynamic table ....

******** Code sample ***********************
Private Sub BuildGrid()
Dim sb As StringBuilder = New StringBuilder("")
Dim bTable As DataTable = objDataset.Tables("Groups")
Dim cTable As New DataTable

Dim dc As DataColumn
Dim dr As DataRow
Dim col As Integer = bTable.Columns.Count
Dim row As Integer = bTable.Rows.Count
Dim str As String = String.Empty
Dim i As Integer = 0
Dim j As Integer = 0

If DatasetIsEmpty(objDataset, bTable) Then
sb.Append("<table border='1'>")
sb.Append("<tr>")
cTable = TransposeTable(bTable, row, col)
sb.Append("<td>Group/Info</td>")
For i = 1 To row 'dc In cTable.Columns row change to column
sb.Append("<td>")
sb.Append("Group " & i)
sb.Append("</td>")
Next
sb.Append("</tr>")

For i = 0 To col - 1 'Each dr In cTable.Rows
' j = 0
' i = 0
'str = String.Empty
sb.Append("<tr>")

sb.Append("<td>")
sb.Append(bTable.Rows(0).Table.Columns(i).ColumnName.ToString)
sb.Append("</td>")

For j = 0 To row - 1 'Each dc In cTable.Columns
' If i = 0 Then
'End If
sb.Append("<td>")
'sb.Append(cTable.Rows(i).Item(j).ToString)

'sb.Append()
Select Case bTable.Rows(j).Table.Columns(i).DataType.ToString
Case "System.Boolean"
sb.Append("<input type='checkbox' name='chk" & j & i & "' value='checkbox' runat='server' />")
Case "System.Byte"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")
Case "System.Char"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.DateTime"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.Decimal"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.Decimal"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.Double"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.Int16"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.Int32"

sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")
Case "System.Int64"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.SByte"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.Single"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.UInt16"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.UInt32"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case "System.UInt64"
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' />")

Case Else
sb.Append("<input type='text' name='txt" & j & i & "' runat='server' value='" & bTable.Rows(j).Item(i).ToString & "' />")
End Select
sb.Append("</td>")

Next
sb.Append("</tr>")

Next

'for i = 1
sb.Append("</table>")
litShow.Text = sb.ToString
Else
Response.Write("Empty Record")
End If

End Sub

******** end of code ************************


3. I want to know how i can capture data dynamically from the table.
Note: Name of control, different control on d same column etc

Thanks
abacus
:sad:

Why not just use the datalist control? You have full control over it then and much better for your situation than the grid

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.