-----------------------------------------------------------
New Message on MumbaiUserGroup
-----------------------------------------------------------
From: sdatye
Message 2 in Discussion
Hi Typically this is done by overriding the ItemDataBound event of the datagrid. You
will have to create a new datagrid inside this event dynamically. Then for each child
row to the corresponding mster row, create a new table again dynamically and bind it
to this new datagrid and make sure that this is placed in between a div tag to give
you the show/hide effect. The sample for that is below: 'Function Name
:ConvertRowsToTable
'Description :Function to convert datarows returned by the select query in
the datagrid's itemdatabound procedure to a datatable
'Last Updated Date :28th Feb 2004
'Inputs :datarow
'Outputs :datatable
Private Function ConvertRowsToTable(ByVal dr() As DataRow) As DataTable
Dim row As DataRow
Dim Table As New DataTable()
Dim i As Int16
Dim column As DataColumn
Try
For i = 1 To dr(0).Table.Columns.Count - 1 With
dr(0).Table.Columns(i)
column = New DataColumn()
column.DataType = .DataType
column.ColumnName = .ColumnName
column.MaxLength = .MaxLength
column.ReadOnly = .ReadOnly
column.Unique = .Unique
Table.Columns.Add(column)
End With Next For Each row In dr
Table.ImportRow(row)
Next
Catch ex As Exception
Dim strErrorString As String
strErrorString = "Error occured while getting child rows"
Server.Transfer("errorpage.aspx?errorstring=" & strErrorString)
End Try
Return Table
End Function
'Function Name :dgMasterRequests_ItemDataBound
'Description :Procedure called by the datagrid's itemdatabound event
'Last Updated Date :28th Feb 2004
'Inputs :system defined parameters
'Outputs :-
Private Sub dgMasterRequests_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgMasterRequests.ItemDataBound
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType =
ListItemType.Item Then
Dim pdr As DataRow
Dim dr() As DataRow
Dim dt As DataTable
Dim gridItem As DataGridItem
Dim tableCell As New TableCell()
Dim lbl As Label
dr = dsHDCallsInfo.Tables("HD_Actv").Select("Sr = '" &
e.Item.Cells(1).Text & "'")
If Not dr Is Nothing And dr.Length > 0 Then dg = New
System.Web.UI.WebControls.DataGrid()
'dg.Width = WebControls.Unit.Percentage(99)
'dg.Width = WebControls.Unit.Pixel(615)
dg.BorderStyle = BorderStyle.Solid
Dim objUnit As New WebControls.Unit(0) dg.BorderWidth
= objUnit
dg.HorizontalAlign = HorizontalAlign.Center
dt = ConvertRowsToTable(dr)
dg.DataSource = dt
dg.ID = e.Item.Cells(1).Text
dg.BackColor = Color.FromArgb(100, 153, 153, 153)
dg.CellPadding = 2
dg.CellSpacing = 1 dg.HeaderStyle.ForeColor =
Color.FromArgb(100, 102, 102, 102)
dg.HeaderStyle.Font.Bold = True
dg.HeaderStyle.CssClass = "activity_header"
dg.ItemStyle.CssClass = "dashboard2"
dg.ItemStyle.VerticalAlign = VerticalAlign.Top
dg.DataBind() gridItem = New DataGridItem(e.Item.ItemIndex,
e.Item.DataSetIndex, ListItemType.Item)
lbl = New Label()
lbl.Text = "<div style='DISPLAY: none;' Font-Size='8' id=" & dg.ID &
">"
tableCell.Controls.Add(lbl)
tableCell.Controls.Add(dg)
lbl = New Label()
lbl.Text = "</div>"
tableCell.Controls.Add(lbl)
tableCell.ColumnSpan = e.Item.Cells.Count
gridItem.Controls.Add(tableCell)
dgMasterRequests.Controls(0).Controls.Add(gridItem)
e.Item.Cells(0).Text = "<a href=javascript:toggleDisplay('" & dg.ID & "') return><img
id='imagefliper" & dg.ID & "' name='imagefliper" & dg.ID & "'
src='images/icon_expand.gif' border = '0'></a>"
e.Item.Cells(1).Text = "<a href=javascript:toggleDisplay1('" & dg.ID &
"')>" & e.Item.Cells(1).Text & "</a>"
End If
If Len(Trim(e.Item.Cells(3).Text)) > 30 Then
e.Item.Cells(3).Text = Mid(e.Item.Cells(3).Text, 1, 30) & "..."
Else
e.Item.Cells(3).Text = Trim(e.Item.Cells(3).Text & "...")
End If
Else
If e.Item.ItemType = ListItemType.Header Then
Dim objUnit As New WebControls.Unit(600)
dgMasterRequests.HeaderStyle.Width = objUnit
End If
End If
End Sub
Hope this will help! Regards, Sarang S. Datye MCSD .NET
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]