Hi all,
I have a very complex page with many sub-levels of hierarchy and I'm encountering some problems on a NestedViewTemplate binding:
System.Web.HttpException was unhandled by user code
Message=DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Domicilio'.
Source=System.Web
ErrorCode=-2147467259
WebEventCode=0
Here is the code of the problematic level:
I use 2 SqlDataSources:
and
I know that those queries can be optimized/reduced and DataGrid layout/paging is actually like "out of the box", but I'm very short of time :(
It seems that DataBinder cannot find SqlDipendentiExtendedSource field but only SqlDipendentiSource ones... how can it be?
thanks in advance for you help!
I have a very complex page with many sub-levels of hierarchy and I'm encountering some problems on a NestedViewTemplate binding:
System.Web.HttpException was unhandled by user code
Message=DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Domicilio'.
Source=System.Web
ErrorCode=-2147467259
WebEventCode=0
Here is the code of the problematic level:
<telerik:GridTableView runat="server" AutoGenerateColumns="False" Caption="Elenco Dipendenti" |
CommandItemDisplay="Bottom" DataKeyNames="DipendentiID" DataSourceID="SqlDipendentiSource" |
AllowSorting="False" EditMode="PopUp" Name="DipendentiView" NoDetailRecordsText="Nessun dipendente per la sede corrente."> |
<CommandItemSettings AddNewRecordText="Aggiungi Dipendente" ShowRefreshButton="False" /> |
<Columns> |
<telerik:GridButtonColumn ButtonType="ImageButton" UniqueName="DipendentiEditCommandColumn" |
CommandName="Edit" HeaderStyle-Width="30px"> |
<HeaderStyle Width="30px"></HeaderStyle> |
<ItemStyle CssClass="MyImageButton" /> |
</telerik:GridButtonColumn> |
<telerik:GridButtonColumn ButtonType="ImageButton" UniqueName="DipendentiDeleteCommandColumn" |
CommandName="Delete" HeaderStyle-Width="30px"> |
<HeaderStyle Width="30px"></HeaderStyle> |
<ItemStyle CssClass="MyImageButton" /> |
</telerik:GridButtonColumn> |
<telerik:GridBoundColumn DataField="DipendentiID" HeaderText="ID" SortExpression="DipendentiID" |
UniqueName="DipendentiID" DataType="System.Int32" ReadOnly="True" HeaderStyle-Width="35px" |
HeaderStyle-HorizontalAlign="Center" AllowFiltering="False"> |
<HeaderStyle HorizontalAlign="Center" Width="35px"></HeaderStyle> |
<ItemStyle HorizontalAlign="Center" /> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Nome" HeaderText="Nome" UniqueName="Nome" DataType="System.String" |
ReadOnly="True" HeaderStyle-HorizontalAlign="Center" AllowFiltering="True"> |
<HeaderStyle HorizontalAlign="Center"></HeaderStyle> |
<ItemStyle HorizontalAlign="Center" /> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Cognome" HeaderText="Cognome" UniqueName="Cognome" |
DataType="System.String" ReadOnly="True" HeaderStyle-HorizontalAlign="Center" |
AllowFiltering="True"> |
<HeaderStyle HorizontalAlign="Center"></HeaderStyle> |
<ItemStyle HorizontalAlign="Center" /> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn UniqueName="Sesso" InitializeTemplatesFirst="false" HeaderStyle-HorizontalAlign="Center" |
AllowFiltering="false"> |
<HeaderTemplate> |
Sesso |
</HeaderTemplate> |
<ItemTemplate> |
<%# (((bool)Eval("Sesso")) ? "M" : "F") %> |
</ItemTemplate> |
<HeaderStyle HorizontalAlign="Center"></HeaderStyle> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn DataField="DataAssunzione" HeaderText="Data di Assunzione" |
UniqueName="DataAssunzione" DataType="System.DateTime" ReadOnly="True" HeaderStyle-HorizontalAlign="Center" |
AllowFiltering="True"> |
<HeaderStyle HorizontalAlign="Center"></HeaderStyle> |
<ItemStyle HorizontalAlign="Center" /> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="DataLicenziamento" HeaderText="Data di Licenziamento" |
UniqueName="DataLicenziamento" DataType="System.DateTime" ReadOnly="True" HeaderStyle-HorizontalAlign="Center" |
AllowFiltering="True"> |
<HeaderStyle HorizontalAlign="Center"></HeaderStyle> |
<ItemStyle HorizontalAlign="Center" /> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Telefono" HeaderText="Telefono" UniqueName="Telefono" |
DataType="System.String" ReadOnly="True" HeaderStyle-HorizontalAlign="Center" |
AllowFiltering="False"> |
<HeaderStyle HorizontalAlign="Center"></HeaderStyle> |
<ItemStyle HorizontalAlign="Center" /> |
</telerik:GridBoundColumn> |
</Columns> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px" /> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px" /> |
</ExpandCollapseColumn> |
<ParentTableRelation> |
<telerik:GridRelationFields DetailKeyField="SediID" MasterKeyField="SediID" /> |
</ParentTableRelation> |
<NestedViewSettings DataSourceID="SqlDipendentiExtendedSource"> |
<ParentTableRelation> |
<telerik:GridRelationFields DetailKeyField="DipendentiID" MasterKeyField="DipendentiID" /> |
</ParentTableRelation> |
</NestedViewSettings> |
<NestedViewTemplate> |
<asp:Panel ID="NestedViewDipendentiPanel" runat="server"> |
<div> |
<fieldset style="padding: 10px;"> |
<legend style="padding: 5px;">Dettagli su: <b> |
<%# Eval("Nome") %> |
<%# Eval("Cognome") %></b></legend> |
<table width="50%"> |
<tr> |
<td> |
Nome: |
</td> |
<td> |
<%# Eval("Nome") %> |
</td> |
</tr> |
<tr> |
<td> |
Cognome: |
</td> |
<td> |
<%# Eval("Cognome") %> |
</td> |
</tr> |
<tr> |
<td> |
Sesso: |
</td> |
<td> |
<%# (((bool)Eval("Sesso")) ? "Maschio" : "Femmina")%> |
</td> |
</tr> |
<tr> |
<td> |
Telefono: |
</td> |
<td> |
<%# Eval("Telefono")%> |
</td> |
</tr> |
<tr> |
<td> |
Domicilio: |
</td> |
<td> |
<%# Eval("Domicilio") %> |
</td> |
</tr> |
<tr> |
<td> |
Residenza: |
</td> |
<td> |
<%# Eval("Residenza") %> |
</td> |
</tr> |
<tr> |
<td> |
Residenza: |
</td> |
<td> |
<%# Eval("Nascita") %> |
</td> |
</tr> |
<tr> |
<td> |
Data di Assunzione: |
</td> |
<td> |
<%# Eval("DataAssunzione") %> |
</td> |
</tr> |
<tr> |
<td> |
Data di Licenziamento: |
</td> |
<td> |
<%# ((Eval("DataLicenziamento") is DBNull) ? "Nessuna" : Eval("DataLicenziamento")) %> |
</td> |
</tr> |
</table> |
</fieldset> |
</div> |
</asp:Panel> |
</NestedViewTemplate> |
<EditFormSettings EditFormType="Template"> |
<FormTemplate> |
</FormTemplate> |
</EditFormSettings> |
</telerik:GridTableView> |
I use 2 SqlDataSources:
<asp:SqlDataSource ID="SqlDipendentiSource" runat="server" ConnectionString="<%$ ConnectionStrings:ReleaseConnection %>" |
SelectCommand="SELECT ML.Dipendenti.id AS DipendentiID, ML.Dipendenti.Nome, ML.Dipendenti.Cognome, ML.Dipendenti.Sesso, ML.Dipendenti.DataAssunzione, ML.Dipendenti.DataLicenziamento, ML.Dipendenti.Telefono, LocalitaPaesi.Via + ' ' + LocalitaPaesi.Numero + ', ' + LocalitaPaesi.NomeComune + ' (' + LocalitaPaesi.ProvinciaSigla + ') ' + LocalitaPaesi.PaeseSigla AS Residenza FROM ML.Dipendenti INNER JOIN LocalitaPaesi ON ML.Dipendenti.LuogoResidenza = LocalitaPaesi.id WHERE (ML.Dipendenti.Sede = @SediID)"> |
<SelectParameters> |
<asp:Parameter Name="SediID" Type="Int32" /> |
</SelectParameters> |
</asp:SqlDataSource> |
and
<asp:SqlDataSource ID="SqlDipendentiExtendedSource" runat="server" ConnectionString="<%$ ConnectionStrings:ReleaseConnection %>" |
SelectCommand="SELECT ML.Dipendenti.id AS DipendentiID, ML.Dipendenti.Nome, ML.Dipendenti.Cognome, ML.Dipendenti.Sesso, ML.Dipendenti.DataAssunzione, ML.Dipendenti.DataLicenziamento, ML.Dipendenti.DataNascita, ML.Dipendenti.Telefono, LocalitaPaesiDomicilio.Via + ' ' + LocalitaPaesiDomicilio.Numero + ', ' + LocalitaPaesiDomicilio.NomeComune + ' (' + LocalitaPaesiDomicilio.ProvinciaSigla + ') ' + LocalitaPaesiDomicilio.PaeseSigla AS Domicilio, LocalitaPaesiLuogoResidenza.Via + ' ' + LocalitaPaesiLuogoResidenza.Numero + ', ' + LocalitaPaesiLuogoResidenza.NomeComune + ' (' + LocalitaPaesiLuogoResidenza.ProvinciaSigla + ') ' + LocalitaPaesiLuogoResidenza.PaeseSigla AS Residenza, LocalitaPaesiLuogoNascita.Via + ' ' + LocalitaPaesiLuogoNascita.Numero + ', ' + LocalitaPaesiLuogoNascita.NomeComune + ' (' + LocalitaPaesiLuogoNascita.ProvinciaSigla + ') ' + LocalitaPaesiLuogoNascita.PaeseSigla AS Nascita, ML.Medici.Nome AS NomeMedico, ML.Medici.Cognome AS CognomeMedico, ML.Medici.Telefono AS TelefonoMedico, LocalitaMedico.Via + ' ' + LocalitaMedico.Numero + ', ' + LocalitaMedico.NomeComune + ' (' + LocalitaMedico.ProvinciaSigla + ') ' + LocalitaMedico.PaeseSigla AS LocalitaMedico FROM ML.Dipendenti INNER JOIN LocalitaPaesi AS LocalitaPaesiDomicilio ON ML.Dipendenti.LuogoResidenza = LocalitaPaesiDomicilio.id INNER JOIN LocalitaPaesi AS LocalitaPaesiLuogoNascita ON ML.Dipendenti.LuogoNascita = LocalitaPaesiLuogoNascita.id INNER JOIN LocalitaPaesi AS LocalitaPaesiLuogoResidenza ON ML.Dipendenti.LuogoResidenza = LocalitaPaesiLuogoResidenza.id INNER JOIN ML.TitoliStudio ON ML.Dipendenti.TitoloStudio = ML.TitoliStudio.id INNER JOIN ML.Medici ON ML.Dipendenti.Medico = ML.Medici.id INNER JOIN LocalitaPaesi AS LocalitaMedico ON ML.Medici.Locazione = LocalitaMedico.id WHERE (ML.Dipendenti.id = @DipendentiID)"> |
<SelectParameters> |
<asp:Parameter Name="DipendentiID" Type="Int32" /> |
</SelectParameters> |
</asp:SqlDataSource> |
I know that those queries can be optimized/reduced and DataGrid layout/paging is actually like "out of the box", but I'm very short of time :(
It seems that DataBinder cannot find SqlDipendentiExtendedSource field but only SqlDipendentiSource ones... how can it be?
thanks in advance for you help!