RE: Nested Datagrid spanning columns of Parent Datagrid

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • RE: On Form Error: MsgBox
    ... just the form) I want it to prompt the first prompt in the code below then ... Can you help me modify the below code to prevent the above error message from ... Private Sub Form_Error(DataErr As Integer, Response As Integer) ...
    (microsoft.public.access.formscoding)
  • Re: Custom error message for Runtime error 3022
    ... The standard error message was triggered as soon as the ... Private Sub Form_Error ... Dim strMsg As String ... I don't think the Form Error triggers by runtime errors, ...
    (comp.databases.ms-access)
  • Re: Where to put my Error handling Code
    ... Private Sub Form_Error ... My error message popped up but then I think ... focus needs to be returned to that control so that the user can change it. ... Error event to display the Error number generated when the user violates your ...
    (microsoft.public.access.formscoding)
  • Re: Modify the Default Error Msg
    ... Private Sub Form_Error(DataErr As Integer, Response As Integer) ... "CASELOAD Error Message" ... continue!", vbCritical, "Caseload Type Error Message" ...
    (microsoft.public.access.forms)
  • i guess i dont understand the OOP style :(
    ... Public Property Get mcTimeAs type_mcTime ... but i got this error message and i really wonder WHY? ... Only public user defined types defined in public object modules can be used ... as parameters or return types for public procedures of class modules or as ...
    (microsoft.public.vb.general.discussion)