Click here to Skip to main content
12,350,121 members (25,605 online)

Silverlight / WPF

 
AnswerRe: Converting WPF windows application to Web Application. Pin
Abhinav S22-Jan-13 2:58
mvpAbhinav S22-Jan-13 2:58 
GeneralRe: Converting WPF windows application to Web Application. Pin
Hema Bairavan22-Jan-13 18:07
memberHema Bairavan22-Jan-13 18:07 
GeneralRe: Converting WPF windows application to Web Application. Pin
Paulo Zemek23-Jan-13 6:22
memberPaulo Zemek23-Jan-13 6:22 
GeneralRe: Converting WPF windows application to Web Application. Pin
Hema Bairavan24-Jan-13 5:30
memberHema Bairavan24-Jan-13 5:30 
AnswerRe: Converting WPF windows application to Web Application. Pin
Pete O'Hanlon21-Jan-13 23:27
protectorPete O'Hanlon21-Jan-13 23:27 
GeneralRe: Converting WPF windows application to Web Application. Pin
Hema Bairavan22-Jan-13 0:24
memberHema Bairavan22-Jan-13 0:24 
AnswerRe: Converting WPF windows application to Web Application. Pin
db7uk26-Jan-13 13:17
memberdb7uk26-Jan-13 13:17 
QuestionGetting sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound." Pin
Geert De Vylder21-Jan-13 4:51
memberGeert De Vylder21-Jan-13 4:51 
Hi all,

I'm working on a WPF solution where I have to populate a combobox depending on the selected item of another combobox. But I get an error.

The XAML code is:

<Window xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
        x:Class="ICP.Reporting.WPFReportViewer.Windows.Report_Script_Resultaten"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        xmlns:navigation="clr-namespace:Infragistics.Silverlight.SampleBrowser.Framework.Controls;assembly=Infragistics.Silverlight.SampleBrowser.Framework"
        xmlns:ig="http://schemas.infragistics.com/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:uri="clr-namespace:ICP.Reporting.WPFReportViewer.Resources.ReportUri"
        xmlns:res="clr-namespace:ICP.Reporting.WPFReportViewer.Resources.Pages"
        d:DesignHeight="500" d:DesignWidth="567" SizeToContent="WidthAndHeight"
        Title="Report Scripts Resultaten"
        WindowStartupLocation="CenterScreen" Icon="/ICP.Reporting.WPFReportViewer;component/Images/Report_New.ico">
 
    <Window.Resources>
        <uri:ReportLibraryUri x:Key="ReportLibraryUri" />
        <res:ParametersStrings x:Key="ParametersStrings" />        
    </Window.Resources>
 
    <Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"/>           
        </Grid.RowDefinitions>
 
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
 
        <StackPanel Name="stackPanelParameters" Orientation="Vertical" VerticalAlignment="Top" Height="Auto" HorizontalAlignment="Center" Width="170" Grid.Row="0" Grid.RowSpan="1" Grid.Column="0" Grid.ColumnSpan="1" Margin="10,5">
            
            <GroupBox Name="groupBoxBeginEindDatum" Header="Kies begin- en einddatum" Height="Auto" Width="Auto" Margin="0,5,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                <StackPanel Name="stackPanelBeginEindDatum" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Height="Auto" Width="Auto" >
                    <!-- <Label Height="28" Content="{Binding Source={StaticResource ParametersStrings}, Path=Binding_StartDate}" Margin="15,10,5,10" Width="77"/> -->
                    <Label Height="20" Content="Begindatum:" Margin="15,5,15,0" Width="77" Padding="5,0" HorizontalAlignment="Center" HorizontalContentAlignment="Center" />
                    <!--<DatePicker Name="datePickerBeginDatum" Height="23" Width="120" SelectedDateFormat="Short" DisplayDate="{x:Static sys:DateTime.Now}" Text="" SelectedDate="{x:Static sys:DateTime.Now}" Margin="5,0" Padding="2" />-->
                    <DatePicker Name="datePickerBeginDatum" Height="23" Width="120" SelectedDateFormat="Short" DisplayDate="01-01-2012" Text="" SelectedDate="01-01-2012" Margin="5,0" Padding="2" />
                    <!-- <Label Height="28" Content="{Binding Source={StaticResource ParametersStrings}, Path=Binding_EndDate}" Margin="15,10,5,10" Width="70"/> -->
                    <Label Height="20" Content="Einddatum:" Margin="15,5,15,0" Width="77" Padding="5,0" HorizontalAlignment="Center" HorizontalContentAlignment="Center" />
                    <!--<DatePicker Name="datePickerEindDatum" Height="23" Width="120" SelectedDateFormat="Short" DisplayDate="{x:Static sys:DateTime.Now}" Text="" SelectedDate="{x:Static sys:DateTime.Now}" Margin="5,0" Padding="2" />-->
                    <DatePicker Name="datePickerEindDatum" Height="23" Width="120" SelectedDateFormat="Short" DisplayDate="12-31-2012" Text="" SelectedDate="12-31-2012" Margin="5,0" Padding="2" />
                </StackPanel>
            </GroupBox>
                        
            <GroupBox Name="groupBoxAuthoriteitScript" Header="En authoriteit en script" Height="Auto" Width="Auto" Margin="0,5,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                <StackPanel Name="stackPanelAuthoriteitScript" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Height="Auto" Width="Auto">
                    <Label Height="20" Content="Authoriteit:" Margin="15,5,15,0" Width="77" Padding="5,0" HorizontalAlignment="Center" HorizontalContentAlignment="Center" />
                    <ComboBox Height="25" Name="comboBoxAuthoriteit" Margin="5,0" Padding="2" SelectedIndex="-1" ItemsSource="{Binding}" DisplayMemberPath="Name" IsSynchronizedWithCurrentItem="True" SelectionChanged="comboBoxAuthoriteit_SelectionChanged" />
                    <Label Height="20" Content="Script:" Margin="15,5,15,0" Width="77" Padding="5,0" HorizontalAlignment="Center" HorizontalContentAlignment="Center" />
                    <ComboBox Height="25" Name="comboBoxScript" Margin="5,0" Padding="2" SelectedIndex="-1" ItemsSource="{Binding}" DisplayMemberPath="Name" />
                </StackPanel>
            </GroupBox>
 
            <GroupBox Name="groupBoxRapport" Header="Rapport" Height="Auto" Width="Auto" Margin="0,5,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                <StackPanel Name="stackPanelRapport" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Height="Auto" Width="Auto">
                    <!-- <Button Content="{Binding Source={StaticResource ParametersStrings}, Path=Refresh}" Margin="20,5,10,5" Click="Button_Refresh_Click" Height="23" Width="61" /> -->
                    <Button Content="Genereer rapport" Margin="5" Click="Button_Refresh_Click" Height="23" Width="100" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </StackPanel>
            </GroupBox>
            
        </StackPanel>
 
        <ig:XamReportViewer HorizontalAlignment="Center" Name="xamReportViewer1" VerticalAlignment="Bottom" PageFit="Width" UseLayoutRounding="True" MinWidth="380" MinHeight="445" PageMargin="0" AutoRender="True" Grid.Row="0" Grid.Column="1" Margin="0">
            <ig:XamReportViewer.RenderSettings>
                <ig:ClientRenderSettings DefinitionUri="/ICP.Reporting.ReportingClassLibrary;component/ReportDesigns/Report_Scripts_Resultaten.igr" />
            </ig:XamReportViewer.RenderSettings>
 
            <!-- Binding parameters -->
            <ig:XamReportViewer.Parameters>
                <ig:Parameter ParameterName="beginDatum" ParameterValue="{Binding ElementName=datePickerBeginDatum, Path=SelectedDate}"/>
                <ig:Parameter ParameterName="eindDatum" ParameterValue="{Binding ElementName=datePickerEindDatum, Path=SelectedDate}"/>
                <!--<ig:Parameter ParameterName="Maand" ParameterValue="{Binding ElementName=comboBoxMaand, Path=SelectedValue}"/>
                <ig:Parameter ParameterName="Jaar" ParameterValue="{Binding ElementName=comboBoxJaar, Path=SelectedValue}"/>
                <ig:Parameter ParameterName="Authoriteit" ParameterValue="{Binding ElementName=comboBoxAuthoriteit, Path=SelectedItem}"/>
                <ig:Parameter ParameterName="Script" ParameterValue="{Binding ElementName=comboBoxScript, Path=SelectedItem}"/>-->
            </ig:XamReportViewer.Parameters>
 
        </ig:XamReportViewer>
    </Grid>
    
</Window>

The code behind is:

using ICP.Reporting.ReportingClassLibrary;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Infragistics.Controls.Reports;
 
namespace ICP.Reporting.WPFReportViewer.Windows
{
    /// <summary>
    /// Interaction logic for Report_Script_Resultaten.xaml
    /// </summary>
    public partial class Report_Script_Resultaten : Window
    {
        public Report_Script_Resultaten()
        {
            InitializeComponent();
 
            CultureInfo ci = CultureInfo.CreateSpecificCulture(CultureInfo.CurrentCulture.Name);
            ci.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
            ci.DateTimeFormat.DateSeparator = "-";
            Thread.CurrentThread.CurrentCulture = ci;
 
            //datePickerBeginDatum.DisplayDate = DateTime.Today.AddDays(-7);
            //datePickerBeginDatum.SelectedDate = DateTime.Today.AddDays(-7);
            //datePickerEindDatum.DisplayDate = DateTime.Today.AddDays(-1);            
            //datePickerEindDatum.SelectedDate = DateTime.Today.AddDays(-1);

            BindComboBoxAuthoriteit(comboBoxAuthoriteit);            
        }
 
        private void Button_Refresh_Click(object sender, RoutedEventArgs e)
        {
            this.xamReportViewer1.Refresh();
        }
 
        public void BindComboBoxAuthoriteit(ComboBox comboBoxName)
        {
            string strConnectionAuthoriteit = ConfigurationManager.ConnectionStrings["ICP.Reporting.ReportingClassLibrary.Properties.Settings.sqlDS_Authorities"].ConnectionString;
            SqlConnection connectionAuthoriteit = new SqlConnection(strConnectionAuthoriteit);
            SqlDataAdapter daAuthoriteit = new SqlDataAdapter("SELECT Authority_ID, Description FROM Authorities ORDER BY Description", connectionAuthoriteit);
            DataSet dsAuthoriteit = new DataSet();
            daAuthoriteit.Fill(dsAuthoriteit, "Authorities");
            comboBoxName.ItemsSource = dsAuthoriteit.Tables[0].DefaultView;
            comboBoxName.DisplayMemberPath = dsAuthoriteit.Tables[0].Columns["Description"].ToString();
            comboBoxName.SelectedValuePath = dsAuthoriteit.Tables[0].Columns["Authority_ID"].ToString();
        }
 
        private void comboBoxAuthoriteit_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBoxAuthoriteit.SelectedIndex > -1)
            {
                BindComboBoxScript(comboBoxScript);
            }
        }
 
        public void BindComboBoxScript(ComboBox comboBoxName)
        {
            string strqryScript = string.Format("SELECT Questionnaire_Id, Questionnaire_Name FROM Questionnaires WHERE (Authority_ID = {0}) ORDER BY Questionnaire_Name", comboBoxAuthoriteit.SelectedItem);
 
            string strConnectionScript = ConfigurationManager.ConnectionStrings["ICP.Reporting.ReportingClassLibrary.Properties.Settings.sqlDS_Scripts"].ConnectionString;
            SqlConnection connectionScript = new SqlConnection(strConnectionScript);            
            SqlDataAdapter daScript = new SqlDataAdapter(strqryScript, connectionScript);
            DataSet dsScript = new DataSet();
            //DataTable dtScript = new DataTable();
            daScript.Fill(dsScript, "Questionnaires");
 
            comboBoxName.ItemsSource = dsScript.Tables[0].DefaultView;
            comboBoxName.DisplayMemberPath = dsScript.Tables[0].Columns["Questionnaire_Name"].ToString();
            comboBoxName.SelectedValuePath = dsScript.Tables[0].Columns["Questionnaire_Id"].ToString();
 
            //foreach (DataRow drScript in dsScript.Tables)
            //{
            //comboBoxScript.Items.Add(drScript[0].ToString());

            //}
        }
    }    
}
When I run the solution I get the sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound."
on the following line:

daScript.Fill(dsScript, "Questionnaires");

Can someone tell me where I'm going wrong and what I have to correct?

Thank you very much for your help.

Greetings,

Geert De Vylder
AnswerRe: Getting sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound." Pin
Mycroft Holmes21-Jan-13 18:36
memberMycroft Holmes21-Jan-13 18:36 
GeneralRe: Getting sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound." Pin
Geert De Vylder21-Jan-13 20:55
memberGeert De Vylder21-Jan-13 20:55 
QuestionBinding to attached property Pin
savbace20-Jan-13 21:22
membersavbace20-Jan-13 21:22 
QuestionRoot element is not valid for navigation Pin
Vuyiswa Maseko19-Jan-13 19:18
memberVuyiswa Maseko19-Jan-13 19:18 
AnswerRe: Root element is not valid for navigation Pin
Richard Deeming21-Jan-13 1:55
memberRichard Deeming21-Jan-13 1:55 
GeneralRe: Root element is not valid for navigation Pin
Vuyiswa Maseko21-Jan-13 4:49
memberVuyiswa Maseko21-Jan-13 4:49 
QuestionRandom Image with array Pin
Tikha17-Jan-13 11:23
memberTikha17-Jan-13 11:23 
AnswerRe: Random Image with array Pin
Pete O'Hanlon17-Jan-13 21:21
protectorPete O'Hanlon17-Jan-13 21:21 
AnswerRe: Random Image with array Pin
Abhinav S19-Jan-13 2:24
mvpAbhinav S19-Jan-13 2:24 
GeneralRe: Random Image with array Pin
Tikha21-Jan-13 17:09
memberTikha21-Jan-13 17:09 
GeneralRe: Random Image with array Pin
Dave Kreskowiak21-Jan-13 17:54
mvpDave Kreskowiak21-Jan-13 17:54 
QuestionDispatcherTimer Tick event not fired Pin
Praveen Raghuvanshi17-Jan-13 4:54
memberPraveen Raghuvanshi17-Jan-13 4:54 
AnswerRe: DispatcherTimer Tick event not fired Pin
Paulo Zemek23-Jan-13 6:28
memberPaulo Zemek23-Jan-13 6:28 
QuestionWhich way to load entity child collections? Pin
UCLAdam16-Jan-13 5:11
memberUCLAdam16-Jan-13 5:11 
QuestionWPF with Web Pin
Rishabh Kumar14-Jan-13 8:42
memberRishabh Kumar14-Jan-13 8:42 
AnswerRe: WPF with Web Pin
Abhishek Pant14-Jan-13 9:17
memberAbhishek Pant14-Jan-13 9:17 
AnswerRe: WPF with Web Pin
Abhinav S16-Jan-13 17:20
mvpAbhinav S16-Jan-13 17:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 24 Jun 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid