RE: Nested Datagrid spanning columns of Parent Datagrid
- From: "Phillip Williams" <WEBSWAPP@xxxxxxxxxxxxxxxxx>
- Date: Wed, 1 Mar 2006 16:14:26 -0800
The code you posted does not seem like the cause of the error message. Can
you post the code that uses this custom control? Also try to use the
debugger with break points at the line that caused the error and look at its
properties; does it have a public property with the name indicated in the
error message?
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Erik" wrote:
Good Morning Phillip,.
I have one error from the conversion I cannot figure out -
'CompanyPrimaryKey' is not a member of 'MIMSearch.ChildDataGrid'
Here is the line it is erroring on:
ChildGrid.CompanyPrimaryKey = iPrimaryKey
Here is the Class:
Public Class ChildDataGrid
Inherits System.Web.UI.UserControl
Protected ChildGrid As System.Web.UI.WebControls.DataGrid
Public Property CompanyPrimaryKey() As Integer
Get
Dim ret As Integer = 0
If Not ViewState("CompanyPrimaryKey") Is Nothing Then
ret = (Int(ViewState("CompanyPrimaryKey")))
End If
Return ret
End Get
Set(ByVal Value As Integer)
ViewState("CompanyPrimaryKey") = Value
DataGrid_Bind()
End Set
End Property
Private Sub DataGrid_Bind()
If Not Data_View() Is Nothing Then
If Data_View().Count > 0 Then
ChildGrid.DataSource = Data_View()
ChildGrid.DataBind()
End If
End If
End Sub
Private Function Data_View() As DataView
Dim dv As DataView = Nothing
Dim ds As DataSet = Session("DataGrid_ParentChild")
If Not ds Is Nothing Then
Dim dvParent As New DataView(ds.Tables("Company"), "ID=" +
CompanyPrimaryKey, Nothing, System.Data.DataViewRowState.CurrentRows)
If (dvParent.Count > 0) Then
dv = dvParent(0).CreateChildView("ParentChild")
End If
End If
Return dv
End Function
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
'Put user code to initialize the page here
End Sub
#Region " Web Form Designer Generated Code "
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
InitializeComponent()
MyBase.OnInit(e)
End Sub
'<summary>
' Required method for Designer support - do not modify
' the contents of this method with the code editor.
' </summary>
Private Sub InitializeComponent()
AddHandler Me.Load, AddressOf Me.Page_Load
End Sub
#End Region
End Class
Any insight is appreciated. This is my first attempt at a custom user
control, and coming from a Progress background I am still getting familiar
with the Microsoft world.
Thanks, Erik
"Erik" wrote:
Thanks again Phillip. I will translate this to vb, and let you know what
happens.
"Phillip Williams" wrote:
My previous answer used the GridView as an example but you can do the same
with the datagrid as in this demo:
http://www.societopia.net/Samples/DataGrid_Hierarchy.aspx
<asp:DataGrid ID="ParentGrid" Runat =server >
<Columns>
<asp:TemplateColumn >
<ItemTemplate >
<table class="DataGridStyle4" border=0 cellpadding=0 cellspacing=1>
<tr>
<!--- this row has the parent Grid in n columns--->
</tr>
<tr >
<!--- this row has the child grid in n-1 columns -->
<td colspan =n-1>
<asp:DataGrid id="ChildGrid1" Runat="server"></asp:DataGrid>
</td>
<td>
<!--- this is the nth columns (which can be left blank-->
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Phillip Williams" wrote:
Hi Erik,
Can you post the markup that you used to give an idea about the final layout
of your nested tables? You might be able to get the result that you want by
re-arranging your templates or by using CSS.
For example, in this demo,
http://www.webswapp.com/codesamples/aspnet20/nestedgridviews/default.aspx
the nested gridview appears as if it spanned n-1 of the columns of the
parentGridView, like this:
<asp:GridView ID="parentGridViw" runat="server" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table border="0" cellpadding="2" cellspacing="0" width="510">
<tr>
<!-- this row has the parent grid implementation on n columns-->
</tr>
<tr>
<td colspan="n-1">
<!-- this row has the child grid which spans n-1 columns of the
parent-->
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Erik" wrote:
Good Morning,
I am trying to write a report which will have a nested datagrid spanning the
columns of the previous line (1st line is the equipment detail information,
2nd line are the user-entered notes for the equipment). When the user notes
are nested in the parent datagrid as a template column on the first line, the
report's length grows to an unacceptable length.
Any insight and suggestions are greatly appreciated.
Thank you, Erik
- Follow-Ups:
- References:
- Prev by Date: Re: How to indent a dropdownlist
- Next by Date: Re: How to indent a dropdownlist
- Previous by thread: RE: Nested Datagrid spanning columns of Parent Datagrid
- Next by thread: RE: Nested Datagrid spanning columns of Parent Datagrid
- Index(es):
Relevant Pages
|