Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I'm using Linq to Sql in my project , and the datagrideview populated by a store procedure called (Get_All_Incomes) .

I design a crystal report to view data from the gridview but there ar an exception say (DataSet does not support System.Nullable<>)

i populate the gridview by this code
dgvIncome.DataSource = CLS_Incomes.Get_All_Incomes().ToList();


i filter the data using this method

string nameFilter = txtCust.Text;
            string mediaFilter = comboMedia.SelectedIndex > 0 ? comboMedia.Text : "";
            string currencyFilter = comboCurr.SelectedIndex > 0 ? comboCurr.Text : "";
            string motalabahFilter = txtMot.Text;
            string sanadFilter = txtSanad.Text;
            string incomeFilter = txtIncome.Text;
            DateTime? fromDate = radioFrom.Checked ? dateTimePicker1.Value.Date : (DateTime?)null;
            DateTime? toDate = radioFrom.Checked ? dateTimePicker2.Value.Date : (DateTime?) null;


            using (dbDataContext db = new dbDataContext())
            {
                var result = from p in db.Get_All_Incomes()
                    where
                        (nameFilter.Length > 0 && p.CustomersName.Contains(nameFilter) || nameFilter.Length == 0)
                        && (mediaFilter.Length > 0 && p.Name == mediaFilter || mediaFilter.Length == 0)
                        && (currencyFilter.Length > 0 && p.CurrencyName == currencyFilter || currencyFilter.Length == 0)
                        && (motalabahFilter.Length > 0 && p.Motalabah == motalabahFilter || motalabahFilter.Length == 0)
                        && (sanadFilter.Length > 0 && p.Sanad == sanadFilter || sanadFilter.Length == 0)
                        && (incomeFilter.Length > 0 && p.Income.ToString() == incomeFilter || incomeFilter.Length == 0)
                        &&
                        ((fromDate == null || toDate == null) ||
                         (fromDate != null && toDate != null && p.SanadDate >= fromDate && p.SanadDate <= toDate))

                    select p;


                dgvIncome.DataSource = result.ToList();


finaly called the Report using this button

btnReport.Cursor = Cursors.WaitCursor;
            Reports.Rpt rpt = new Reports.Rpt();
            rpt.SetDataSource(dgvIncome.DataSource);
            FRM_Report frm = new FRM_Report();
            btnReport.Cursor = Cursors.Default;
            frm.ShowDialog();
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900