The following works just fine:
myStatements = db.Statements.Select(s => new StatementModel
{
StatmentId = s.StatementId,
EmployeeNumber = s.EmployeeNumber,
FirstName = s.Employee.FirstName,
LastName = s.Employee.LastName,
PlanVariantType = s.Employee.PlanVariantType != null ? s.Employee.PlanVariantType.PlanVariantTypeName : "",
FiscalPeriod = s.FiscalPeriod != null ? s.FiscalPeriod.FiscalPeriodName : "",
CostCenterId = s.Employee.CostCenterId,
EVPName = s.Employee.CostCenter.Evp != null ? s.Employee.CostCenter.Evp.FirstName + " " + s.Employee.CostCenter.Evp.LastName : "",
SVPName = s.Employee.CostCenter.Svp != null ? s.Employee.CostCenter.Svp.FirstName + " " + s.Employee.CostCenter.Svp.LastName : "",
LOBMgrName = s.Employee.CostCenter.Lobmgr != null ? s.Employee.CostCenter.Lobmgr.FirstName + " " + s.Employee.CostCenter.Lobmgr.LastName : "",
AdminApprovalStatus = s.AdminApprovalStatus.ApprovalStatusName,
StatementStatus = s.StatementStatus.StatementStatusName,
AmountDue = s.AmountDue
}).ToList();
But if I add a simple WHERE clause it throws an exception saying it can't be translated:
myStatements = db.Statements.Select(s => new StatementModel
{
StatmentId = s.StatementId,
EmployeeNumber = s.EmployeeNumber,
FirstName = s.Employee.FirstName,
LastName = s.Employee.LastName,
PlanVariantType = s.Employee.PlanVariantType != null ? s.Employee.PlanVariantType.PlanVariantTypeName : "",
FiscalPeriod = s.FiscalPeriod != null ? s.FiscalPeriod.FiscalPeriodName : "",
CostCenterId = s.Employee.CostCenterId,
EVPName = s.Employee.CostCenter.Evp != null ? s.Employee.CostCenter.Evp.FirstName + " " + s.Employee.CostCenter.Evp.LastName : "",
SVPName = s.Employee.CostCenter.Svp != null ? s.Employee.CostCenter.Svp.FirstName + " " + s.Employee.CostCenter.Svp.LastName : "",
LOBMgrName = s.Employee.CostCenter.Lobmgr != null ? s.Employee.CostCenter.Lobmgr.FirstName + " " + s.Employee.CostCenter.Lobmgr.LastName : "",
AdminApprovalStatus = s.AdminApprovalStatus.ApprovalStatusName,
StatementStatus = s.StatementStatus.StatementStatusName,
AmountDue = s.AmountDue
}).Where(s => s.StatementStatusId == "PAA").ToList();
The exception message is a mess and isn't helpful beyond telling me that it couldn't be translated.
So what's the issue with the WHERE clause?
Try this. Use where clause first then projection.
myStatements = db.Statements.Where(s => s.StatementStatusId == "PAA").Select(s => new StatementModel
{
StatmentId = s.StatementId,
EmployeeNumber = s.EmployeeNumber,
FirstName = s.Employee.FirstName,
LastName = s.Employee.LastName,
PlanVariantType = s.Employee.PlanVariantType != null ? s.Employee.PlanVariantType.PlanVariantTypeName : "",
FiscalPeriod = s.FiscalPeriod != null ? s.FiscalPeriod.FiscalPeriodName : "",
CostCenterId = s.Employee.CostCenterId,
EVPName = s.Employee.CostCenter.Evp != null ? s.Employee.CostCenter.Evp.FirstName + " " + s.Employee.CostCenter.Evp.LastName : "",
SVPName = s.Employee.CostCenter.Svp != null ? s.Employee.CostCenter.Svp.FirstName + " " + s.Employee.CostCenter.Svp.LastName : "",
LOBMgrName = s.Employee.CostCenter.Lobmgr != null ? s.Employee.CostCenter.Lobmgr.FirstName + " " + s.Employee.CostCenter.Lobmgr.LastName : "",
AdminApprovalStatus = s.AdminApprovalStatus.ApprovalStatusName,
StatementStatus = s.StatementStatus.StatementStatusName,
AmountDue = s.AmountDue
}).ToList();
Problem here that you have custom projection. It means that LINQ translator knows only fields which are explicitly mapped. StatementStatusId has no mapping and Translator throws error. Add mapping and query will work:
myStatements = db.Statements.Select(s => new StatementModel
{
StatmentId = s.StatementId,
EmployeeNumber = s.EmployeeNumber,
FirstName = s.Employee.FirstName,
LastName = s.Employee.LastName,
PlanVariantType = s.Employee.PlanVariantType != null ? s.Employee.PlanVariantType.PlanVariantTypeName : "",
FiscalPeriod = s.FiscalPeriod != null ? s.FiscalPeriod.FiscalPeriodName : "",
CostCenterId = s.Employee.CostCenterId,
EVPName = s.Employee.CostCenter.Evp != null ? s.Employee.CostCenter.Evp.FirstName + " " + s.Employee.CostCenter.Evp.LastName : "",
SVPName = s.Employee.CostCenter.Svp != null ? s.Employee.CostCenter.Svp.FirstName + " " + s.Employee.CostCenter.Svp.LastName : "",
LOBMgrName = s.Employee.CostCenter.Lobmgr != null ? s.Employee.CostCenter.Lobmgr.FirstName + " " + s.Employee.CostCenter.Lobmgr.LastName : "",
AdminApprovalStatus = s.AdminApprovalStatus.ApprovalStatusName,
StatementStatus = s.StatementStatus.StatementStatusName,
AmountDue = s.AmountDue,
// missing mapping
StatementStatusId = s.StatementStatusId
}).Where(s => s.StatementStatusId == "PAA").ToList();
Related
I am using VS2013 and crystal report 2013
I am passing 30 parameters to crystal report.
It is working fine for 5 times, Then I got the next error:-
Memory Full. Not Enough memory for operation.
What I tried so far:-
using CrystalReport1.Refresh(); without solving the problem.
Appreciate any help.
Edit 1:-
I know maybe my question has lack of info but I think there is no any details could help you, any ways here you are the extra info I hope it will be useful.
I have Application as next:-
when I click Print it is working fine as next
if I close the window and press Print again it is working fine for 5 or 6 times,
then I faced the next error:-
Edit 2:-
My code is:-
1) Create new form and drag and drop crystal report viewer.
2) at the load event I wrote the next code:-
private void frmReport_Load(object sender, EventArgs e)
{
try
{
CrystalReport11.SetParameterValue("pName", PatientName);
CrystalReport11.SetParameterValue("pAge", Age);
CrystalReport11.SetParameterValue("pDate", Date);
CrystalReport11.SetParameterValue("P1", Number1);
CrystalReport11.SetParameterValue("P2", Number2);
CrystalReport11.SetParameterValue("P3", Number3);
CrystalReport11.SetParameterValue("P4", Number4);
CrystalReport11.SetParameterValue("P5", Number5);
CrystalReport11.SetParameterValue("P6", Number6);
CrystalReport11.SetParameterValue("P7", Number7);
CrystalReport11.SetParameterValue("pDrugsName1", DrugName1);
CrystalReport11.SetParameterValue("pDrugsName2", DrugName2);
CrystalReport11.SetParameterValue("pDrugsName3", DrugName3);
CrystalReport11.SetParameterValue("pDrugsName4", DrugName4);
CrystalReport11.SetParameterValue("pDrugsName5", DrugName5);
CrystalReport11.SetParameterValue("pDrugsName6", DrugName6);
CrystalReport11.SetParameterValue("pDrugsName7", DrugName7);
CrystalReport11.SetParameterValue("pQTY1", QTY1);
CrystalReport11.SetParameterValue("pQTY2", QTY2);
CrystalReport11.SetParameterValue("pQTY3", QTY3);
CrystalReport11.SetParameterValue("pQTY4", QTY4);
CrystalReport11.SetParameterValue("pQTY5", QTY5);
CrystalReport11.SetParameterValue("pQTY6", QTY6);
CrystalReport11.SetParameterValue("pQTY7", QTY7);
CrystalReport11.SetParameterValue("pTimeOfUse1", TimeOfUse1);
CrystalReport11.SetParameterValue("pTimeOfUse2", TimeOfUse2);
CrystalReport11.SetParameterValue("pTimeOfUse3", TimeOfUse3);
CrystalReport11.SetParameterValue("pTimeOfUse4", TimeOfUse4);
CrystalReport11.SetParameterValue("pTimeOfUse5", TimeOfUse5);
CrystalReport11.SetParameterValue("pTimeOfUse6", TimeOfUse6);
CrystalReport11.SetParameterValue("pTimeOfUse7", TimeOfUse7);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
and I am calling the form via next code:-
DrugName1 = (txtDrugsName1.Text == string.Empty) ? " " : txtDrugsName1.Text;
DrugName2 = (txtDrugsName2.Text == string.Empty) ? " " : txtDrugsName2.Text;
DrugName3 = (txtDrugsName3.Text == string.Empty) ? " " : txtDrugsName3.Text;
DrugName4 = (txtDrugsName4.Text == string.Empty) ? " " : txtDrugsName4.Text;
DrugName5 = (txtDrugsName5.Text == string.Empty) ? " " : txtDrugsName5.Text;
DrugName6 = (txtDrugsName6.Text == string.Empty) ? " " : txtDrugsName6.Text;
DrugName7 = (txtDrugsName7.Text == string.Empty) ? " " : txtDrugsName7.Text;
Number1 = (txtDrugsName1.Text == string.Empty) ? " " : "1";
Number2 = (txtDrugsName2.Text == string.Empty) ? " " : "2";
Number3 = (txtDrugsName3.Text == string.Empty) ? " " : "3";
Number4 = (txtDrugsName4.Text == string.Empty) ? " " : "4";
Number5 = (txtDrugsName5.Text == string.Empty) ? " " : "5";
Number6 = (txtDrugsName6.Text == string.Empty) ? " " : "6";
Number7 = (txtDrugsName7.Text == string.Empty) ? " " : "7";
QTY1 = (cmbQTY1.Text == string.Empty) ? " " : cmbQTY1.Text;
QTY2 = (cmbQTY2.Text == string.Empty) ? " " : cmbQTY2.Text;
QTY3 = (cmbQTY3.Text == string.Empty) ? " " : cmbQTY3.Text;
QTY4 = (cmbQTY4.Text == string.Empty) ? " " : cmbQTY4.Text;
QTY5 = (cmbQTY5.Text == string.Empty) ? " " : cmbQTY5.Text;
QTY6 = (cmbQTY6.Text == string.Empty) ? " " : cmbQTY6.Text;
QTY7 = (cmbQTY7.Text == string.Empty) ? " " : cmbQTY7.Text;
TimeOfUse1 = (cmbTimeOfUse1.Text == string.Empty) ? " " : cmbTimeOfUse1.Text;
TimeOfUse2 = (cmbTimeOfUse2.Text == string.Empty) ? " " : cmbTimeOfUse2.Text;
TimeOfUse3 = (cmbTimeOfUse3.Text == string.Empty) ? " " : cmbTimeOfUse3.Text;
TimeOfUse4 = (cmbTimeOfUse4.Text == string.Empty) ? " " : cmbTimeOfUse4.Text;
TimeOfUse5 = (cmbTimeOfUse5.Text == string.Empty) ? " " : cmbTimeOfUse5.Text;
TimeOfUse6 = (cmbTimeOfUse6.Text == string.Empty) ? " " : cmbTimeOfUse6.Text;
TimeOfUse7 = (cmbTimeOfUse7.Text == string.Empty) ? " " : cmbTimeOfUse7.Text;
frmReport obj = new frmReport(
txtPatientName.Text,
nudAge.Value.ToString(),
dtpDate.Text,
DrugName1,
DrugName2,
DrugName3,
DrugName4,
DrugName5,
DrugName6,
DrugName7,
QTY1,
QTY2,
QTY3,
QTY4,
QTY5,
QTY6,
QTY7,
TimeOfUse1,
TimeOfUse2,
TimeOfUse3,
TimeOfUse4,
TimeOfUse5,
TimeOfUse6,
TimeOfUse7,
Number1,
Number2,
Number3,
Number4,
Number5,
Number6,
Number7
);
obj.ShowDialog();
I had the same problem and this worked for me too:
into frmReport_FormClosing Type crystalReportViewer1.Dispose(); and CrystalReport11.Dispose();
Im trying to convert an object (Lead) to a reduced form of the same object (ApiLead)
The object contains a list of objects (OtherInHousehold) which also needs to be reduced (ApiOtherInHousehold):
result = leads.Select(lead => new ApiLead()
{
UserId = lead.UserId,
DepartmentId = lead.DepartmentId,
CompanyId = lead.CompanyId,
CPR_number = lead.CPR_number,
CVR_number = lead.CVR_number,
Name = (lead.FirstName == "[virksomhed]" ? "" : lead.FirstName + " ") + lead.LastName,
Address = (lead.Street + " " + lead.StreetNumber + " " + lead.Floor + " " + lead.Side).Trim(),
Zipcode = lead.Zipcode,
City = (lead.PlaceName + " " + lead.City).Trim(),
Phonenumber = ("Fastnet: " + lead.Phonenumber + " Mobil: " + lead.Cellphonenumber),
Email = lead.Email,
BestReached = lead.BestReached,
**OthersInHousehold = lead.OthersInHousehold.Select(oih => new ApiOtherInHousehold(){ CPR_number = oih.CPR_number, Name = oih.Name }).ToList()**,
WantsVisit = lead.WantsVisit,
WantsPhonecall = lead.WantsPhonecall,
WantsInsuranceImmediately = lead.WantsInsuranceImmediately,
ExistingInsurance = lead.ExistingInsurance,
CurrentInsuranceCompany = lead.CurrentInsuranceCompany,
OtherInfo = lead.OtherInfo,
Status = lead.Status,
CreationDate = lead.CreationDate
}).ToList();
But this throws an
Cannot implicitly convert type 'System.Collections.Generic.List<LeadsApp.ApiModels.ApiLead>' to
'System.Collections.Generic.List<LeadsApp.Models.Lead>'
Is this not possible or am I doing it wrong?
Thanks, guys.
At the linq statement, you are returning List<ApiLead>. But result variable is List<Lead>. You have to declare your result variable as List<ApiLead>.
Hope helps,
i'm making a web-service where i'm calling data-objects who are created directly through linq, i was wondering, how i can convert DateTime? directly to string?, this, because i can't convert the DateTime? to DateTime and then to string through a variable or a what not, because linq don't let me.
Here's the code:
lista = (from p in db.Acciones
select new ItemAcciones
{
ID_Accion = p.ID_Accion,
FechaHora = p.FechaHora != null ? (DateTime)p.FechaHora : DateTime.Now,
//ShowFechaHora = !String.IsNullOrWhiteSpace(((DateTime)p.FechaHora).ToString("HH:mm")) ? ((DateTime)p.FechaHora).ToString("HH:mm") : DateTime.Now.ToString("HH:mm"),
ID_EmpresaNombre = p.Empresas.EmpresaNombre,
ID_ResponsableNombre = p.Responsables.LoginID,
ID_ContactoNombre = p.Contactos.Nombres + " " + p.Contactos.Paterno + " " + p.Contactos.Materno,
ID_AccionTipoNombre = p.AccionTipos.AccionTipoGlosa,
ID_AccionEstadoNombre = p.AccionEstados.AccEstGlosa,
AccionGlosa = p.AccionGlosa,
ID_Empresa = p.ID_Empresa,
AccionDescripcion = p.AccionDescripcion,
ID_Negocio = (int?)p.ID_Negocio ?? 0,
ID_Contacto = p.ID_Contacto,
ID_AccionTipo = p.ID_AccionTipo,
ID_AccionEstado = p.ID_AccionEstado,
ID_ProgFecha = p.ID_ProgFecha != null ? (int)p.ID_ProgFecha : 0,
ShowID_ProgFecha = String.IsNullOrWhiteSpace(p.ID_ProgFecha.ToString()) ?? p.ID_ProgFecha.ToString() : "--/--/----",
//ShowID_ProgFecha = StringAEstilizarComoDate(Convert.ToString(p.ID_ProgFecha)),
ID_ProgHora = p.ID_ProgHora != null ? (int)p.ID_ProgHora : 0,
//ShowID_ProgHora = StringAEstilizarComoHora(Convert.ToString(p.ID_ProgHora)),
ID_EjecFecha = p.ID_EjecFecha != null ? (int)p.ID_EjecFecha : 0,
//ShowID_EjecFecha = StringAEstilizarComoDate(Convert.ToString(p.ID_EjecFecha)),
ID_EjecHora = p.ID_EjecHora != null ? (int)p.ID_EjecHora : 0,
//ShowID_EjecHora = StringAEstilizarComoHora(Convert.ToString(p.ID_EjecHora)),
ID_Responsable = p.ID_Responsable,
EmpresaRUTCompleto = p.Empresas.EmpresaRut.ToString() + "-" + p.Empresas.EmpresaDV,
ID_NegocioNombre = p.Negocios.ProyectoNombre,
}).ToList();
Any question, suggestion or comment to improve the question would be appreciated as well as the answer.
It's a manually solution, but you can use SqlFunctions to handle the string for your Date.
var qqqq = db.YourTable.Select(q => (q.YourDate == null ? "" : (SqlFunctions.DateName("day",q.YourDate) + "/" + SqlFunctions.DateName("month", q.YourDate) + "/" + SqlFunctions.DateName("year", q.YourDate) + " " + SqlFunctions.DateName("hour", q.YourDate) + " " + SqlFunctions.DateName("minute", q.YourDate)))).ToList();
Hope that helps. =)
here is my sample xml file:
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<title>Title goes here</title>
<author><name>None</name></author>
<source>
<title>Adhocs Source - Adhocs Section</title>
<id>None</id>
<updated>2015-07-21T17:45:20.387248Z</updated>
</source>
<link rel="alternate" href="http://www.example.com/" />
<id>http://www.example.com/</id>
<updated>2015-07-21T17:45:20.387248Z</updated>
<published>2015-07-21T17:45:20.387248Z</published>
<summary>sample desc goes here...</summary>
<media:thumbnail
xmlns:media="http://search.yahoo.com/mrss/"
url="http://mscrmblog.net/wp-content/uploads/2013/10/iframe-loading.png" />
</entry>
</feed>
when i am trying to read this using c# Linq to XML query using below code:
XElement _atom = XElement.Load(atom);
XNamespace nsMedia = "http://search.yahoo.com/mrss/";
XNamespace nsAtom = "http://www.w3.org/2005/Atom";
var temp = (from item in _atom.Descendants(nsAtom + "entry")
select new FinalListToBeDisplayed()
{
Title = item.Element(nsAtom + "title") == null ? "" : item.Element(nsAtom + "title").Value,
Description = item.Element(nsAtom + "summary") == null ? "" : item.Element(nsAtom + "summary").Value,
PublishedDate = item.Element(nsAtom + "published") == null ? "" : item.Element(nsAtom + "published").Value,
Link = item.Element(nsAtom + "link") == null ? "" : item.Element(nsAtom + "link").Attribute("href") == null ? "" : item.Element(nsAtom + "link").Attribute("href").Value,
Image = item.Element(nsMedia + "thumbnail") == null ? "" : item.Element(nsMedia + "thumbnail").Attribute(nsAtom + "url") != null ? item.Element(nsMedia + "thumbnail").Attribute(nsAtom + "url").Value : ""
}).ToList();
Image is not capturing at any moment, i.e. the above code is not able to read thumbnails . Please help me to understand the issue in the above code.
Try this
XElement _atom = XElement.Load(atom);
XNamespace nsMedia = "http://search.yahoo.com/mrss/";
XNamespace nsAtom = "http://www.w3.org/2005/Atom";
var temp = (from item in _atom.Descendants(nsAtom + "entry")
select new
{
Title = item.Element(nsAtom + "title") == null ? "" : item.Element(nsAtom + "title").Value,
Description = item.Element(nsAtom + "summary") == null ? "" : item.Element(nsAtom + "summary").Value,
PublishedDate = item.Element(nsAtom + "published") == null ? "" : item.Element(nsAtom + "published").Value,
Link = item.Element(nsAtom + "link") == null ? "" : item.Element(nsAtom + "link").Attribute("href") == null ? "" : item.Element(nsAtom + "link").Attribute("href").Value,
Image = item.Element(nsMedia + "thumbnail") == null ? "" : item.Element(nsMedia + "thumbnail").Attribute("url") != null ? item.Element(nsMedia + "thumbnail").Attribute("url").Value : ""
}).ToList();
The issue is the attribute name for url. url does not have a namespace, but you are including the http://www.w3.org/2005/Atom namespace as part of the name. Remove this and use url and it will work.
I'd also comment that you can use the methods that return a sequence combined with the explicit conversions built into XElement and XAttribute to avoid your null checks. This achieves the same result but is a lot cleaner:
Title = (string)item.Element(nsAtom + "title") ?? "",
Description = (string)item.Element(nsAtom + "summary") ?? "",
PublishedDate = (string)item.Element(nsAtom + "published") ?? "",
Link = (string)item.Elements(nsAtom + "link")
.Attributes("href")
.SingleOrDefault() ?? "",
Image = (string)item.Elements(nsMedia + "thumbnail")
.Attributes("url")
.SingleOrDefault() ?? ""
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
If I write in cmbGrNo.text then there will be an
Input string is not in correct format
How can I identify that which combobox is edit?
I write in combobox and then click on search button the compiler is giving me error cause it does not accept the other combobox text. It only accepts the value of first one ...
please help me
HERE IS THE CODE
private void btnSearch_Click(object sender, EventArgs e)
{
if (cmbAdmissionNo.Text.Length == 0 && cmbRollNo.Text.Length == 0 && cmbStudentName.Text.Length == 0 && cmbGRNo.Text.Length == 0)
{
MessageBox.Show("Enter Student Name OR Admission No OR Gr No OR Roll No"," INSERT FIELDS", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (StudentDBClass.CheckStudent(cmbStudentName.Text))
{
DataTable dt = StudentDBClass.getTableBYStdName(cmbStudentName.Text);
txtAdminNo.Text = "Admission No : " + dt.Rows[0]["AddmissionNo"];
txtGrNo.Text = "GR No : " + dt.Rows[0]["GRNo"];
txtClass.Text = "Class : " + dt.Rows[0]["ClassName"];
txtStudentName.Text = "Student Name : " + dt.Rows[0]["StudentName"];
txtFatherName.Text = "Father Name : " + dt.Rows[0]["FatherName"];
txtRollNo.Text = "Roll No: " + dt.Rows[0]["RollNo"];
dgvStdFeeCollection.DataSource = null;
dgvStdFeeCollection.DataSource = StudentFeeCollectionDBClass.getStdNameForDgvFeeCollection(cmbStudentName.Text);
cmbAdmissionNo.SelectedIndex = -1;
cmbGRNo.SelectedIndex = -1;
cmbRollNo.SelectedIndex = -1;
cmbAdmissionNo.Text = string.Empty;
cmbGRNo.Text = string.Empty;
cmbRollNo.Text = string.Empty;
}
else if (StudentDBClass.CheckWithAdmissionNo(Convert.ToInt32(cmbAdmissionNo.Text)))
{
DataTable dt = StudentDBClass.getTableBYAddmissionNo(Convert.ToInt32(cmbAdmissionNo.Text));
txtAdminNo.Text = "Admission No : " + dt.Rows[0]["AddmissionNo"];
txtGrNo.Text = "GR No : " + dt.Rows[0]["GRNo"];
txtClass.Text = "Class : " + dt.Rows[0]["ClassName"];
txtStudentName.Text = "Student Name : " + dt.Rows[0]["StudentName"];
txtFatherName.Text = "Father Name : " + dt.Rows[0]["FatherName"];
txtRollNo.Text = "Roll No: " + dt.Rows[0]["RollNo"];
dgvStdFeeCollection.DataSource = null;
dgvStdFeeCollection.DataSource = StudentFeeCollectionDBClass.getAdmissionNoForDgvFeeCollection(Convert.ToInt32(cmbAdmissionNo.Text));
cmbStudentName.SelectedIndex = -1;
cmbGRNo.SelectedIndex = -1;
cmbRollNo.SelectedIndex = -1;
cmbGRNo.Text = string.Empty;
cmbStudentName.Text = string.Empty;
cmbRollNo.Text = string.Empty;
}
else if (StudentDBClass.CheckGRNo(Convert.ToInt32(cmbGRNo.Text)))
{
DataTable dt = StudentDBClass.getTableGrNo(Convert.ToInt32(cmbGRNo.Text));
txtAdminNo.Text = "Admission No : " + dt.Rows[0]["AddmissionNo"];
txtGrNo.Text = "GR No : " + dt.Rows[0]["GRNo"];
txtClass.Text = "Class : " + dt.Rows[0]["ClassName"];
txtStudentName.Text = "Student Name : " + dt.Rows[0]["StudentName"];
txtFatherName.Text = "Father Name : " + dt.Rows[0]["FatherName"];
txtRollNo.Text = "Roll No: " + dt.Rows[0]["RollNo"];
dgvStdFeeCollection.DataSource = null;
dgvStdFeeCollection.DataSource = StudentFeeCollectionDBClass.getGrNoForDgvFeeCollection(Convert.ToInt32(cmbGRNo.Text));
cmbAdmissionNo.SelectedIndex = -1;
cmbStudentName.SelectedIndex = -1;
cmbRollNo.SelectedIndex = -1;
cmbAdmissionNo.Text = string.Empty;
cmbStudentName.Text = string.Empty;
cmbRollNo.Text = string.Empty;
}
This error occurs when the Convert.ToInt32 receives a string that its not able to parse.
You are selecting the text value of the combobox, this will not return an integer.
You need to select the SelectedValue of the combobox.
Something like this:
Convert.ToInt32(cmbGrNo.SelectedValue.Text)