Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / Internal error: can't convert to DestinationValue.

Internal error: can't convert to DestinationValue.

New Discussion
akram khan
akram khan asked on Sep 17, 2015 2:11 PM

Hi all,

I am getting the subjected error when i execute the following code. can anyone guide me where is the error in this code.

private void SearchOnUserCodesAdapterShowDialog(string TypeID,Epicor.Mfg.UI.FrameWork.EpiUltraCombo Ctr)
{
// Wizard Generated Search Method
// You will need to call this method from another method in custom code
// For example, [Form]_Load or [Button]_Click
UserCodesAdapter UserCodesAdapter = new UserCodesAdapter(oTrans);
UserCodesAdapter.BOConnect();

bool avail = UserCodesAdapter.GetByID(TypeID);

if(avail)
{

{
Ctr.ValueMember = “CodeID”;
// Set EpiUltraCombo Properties
if(TypeID == “RunningNum”)
{
Ctr.ValueMember = “CodeDesc”;

string str1 =””;
DataRow row = this.edvProject.CurrentDataRow;
if(row!=null)
str1= row[“ShortChar01”].ToString();
Ctr.DataSource = UserCodesAdapter.UserCodesData.UDCodes.Select(“CodeID = ‘” + str1 + “‘”);

//MessageBox.Show(str1);

if(((DataRow[])Ctr.DataSource).Length>0)
{
//string[] strKey = new string[]
//for(int i=0;i< UserCodesAdapter.UserCodesData.UDCodes.Rows.Count; i++)
{
UserCodesAdapter.UserCodesData.UDCodes.Rows[0][“CodeDesc”] = Convert.ToDouble(UserCodesAdapter.UserCodesData.UDCodes.Rows[0][“CodeDesc”]) + 1;

}
//Ctr.ValueMember = “CodeDesc”;
// Ctr.DisplayMember = “CodeDesc”;
//((DataRow[])Ctr.DataSource)[0][“CodeDesc”] = Convert.ToDouble(((DataRow[])Ctr.DataSource)[0][“CodeDesc”]) + 1;
//MessageBox.Show(((DataRow[])Ctr.DataSource)[0][“CodeDesc”].ToString());
}
}
else if(TypeID ==”DepIdent”)
{
string str =””;
DataRow row = this.edvProject.CurrentDataRow;
if(row!=null)
str= row[“ShortChar01”].ToString();
Ctr.DataSource = UserCodesAdapter.UserCodesData.UDCodes.Select(“Character01 = ‘” + str + “‘”);
}

else
Ctr.DataSource = UserCodesAdapter.UserCodesData.UDCodes;

Ctr.DisplayMember = “CodeDesc”;
string[] fields = new string[] {“CodeDesc”};
Ctr.SetColumnFilter(fields);

}
}
UserCodesAdapter.Dispose();

}

bool runningnum_selected = false;
private void Project_BeforeFieldChange(object sender, DataColumnChangeEventArgs args)
{
// ** Argument Properties and Uses **
// args.Row[“FieldName”]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
switch (args.Column.ColumnName)
{
case “ShortChar04”:
runningnum_selected = true;
break;
}
}
private void edvProject_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
// ** Argument Properties and Uses **
// view.dataView[args.Row][“FieldName”]
// args.Row, args.Column, args.Sender, args.NotifyType
// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
// if ((args.NotifyType == EpiTransaction.NotifyType.AddRow))
// {
if ((args.Row > -1))
{
runningnum_selected = false;
{
SearchOnUserCodesAdapterShowDialog(“RunningNum”,cbxRunningNum);
}
//}
}
}
}

Regards,

Akram

Sign In to post a reply

Replies

  • 0
    Hristo Goshev
    Hristo Goshev answered on Aug 19, 2015 10:22 AM

    Hello ,

     

    Based on the code snipped it seems that you are using Epicore components and Infragistics forum is for a questions related to the Infragistics components.

    Common guidance to this issue is that some of the cell values do not returns you a double value and Convert fails. Since this is some kind of grid my assumption is that some cells returns you DbNull.Value (or maybe NaN) which cause your issue. However my advice is for a better support to ask the vendor of the components you are using (i.e. Epicor).

  • 0
    Mike Saltzman
    Mike Saltzman answered on Aug 19, 2015 2:50 PM

    Just to give you a little more info… that error message indicates that there is a cell in the grid that is trying to convert the cell's value into something the cell editor can display and failing to do so.

    The usually occurs when a cell is edited or assigned a value. But you seem to be saying that it happens when the grid displays or is bound without any user intervention.

    The grid is pretty good about picking the correct editor based on the data type of the column in the data source. So if you are getting this error without editing a cell, it could be because you assigned an editor to a column and that editor is not appropriate for the data type of that column. Or, it could be that your data source is using a data type that the grid simply cannot support. As far as I know, the latter case has never happened, though, so that seems unlikely. The grid typically just falls back to displaying the ToString of the value if it doesn't recognize the data type.

    • 0
      akram khan
      akram khan answered on Aug 27, 2015 1:48 PM

      Hi,

      When i comment the code(cbxRunningNum.DropDownStyle = Infragistics.Win.UltraWinGrid.UltraComboStyle.DropDownList;) for drop down style , i am not getting this internal error. whereas when i change the selection of division the running number should match that division, when i drop down it is appearing but, we can edit the combo also, it there any other way apart from (cbxRunningNum.DropDownStyle = Infragistics.Win.UltraWinGrid.UltraComboStyle.DropDownList;) so that the combo is non editable. 

      please let me know if you dont understand my concern . 

      Regards,

      akram

      • 0
        Mike Saltzman
        Mike Saltzman answered on Aug 27, 2015 3:15 PM

        Hi Akram,

        [quote user="akram khan"]When i comment the code(cbxRunningNum.DropDownStyle = Infragistics.Win.UltraWinGrid.UltraComboStyle.DropDownList;) for drop down style , i am not getting this internal error[/quote]

        This says to me that you have a ValueList, Editor, or EditorControl applied to this column and the items on the list don't match the DataType of the column and that's why the grid is unable to convert the values.

        So what is the DataType of the column and what are the DataTypes of the items in the list?

      • 0
        akram khan
        akram khan answered on Aug 30, 2015 6:15 AM

        Hi Mike,

        The data type of the combo is char and the datatype of the value list is char which is converted to double and displayed in value list. 

        Regards,

        akram 

      • 0
        akram khan
        akram khan answered on Aug 30, 2015 6:16 AM

        ((DataRow[])Ctr.DataSource)[0]["CodeDesc"] = Convert.ToDouble(((DataRow[])Ctr.DataSource)[0]["CodeDesc"]) + 1

      • 0
        Mike Saltzman
        Mike Saltzman answered on Aug 31, 2015 2:50 PM

        Well, that's the problem, then. Why are you converting a char to a double? I'm pretty sure that C# will allow you to implicitly convert a char to an int and vice versa, but a char has no implicit conversion to a double.

        There are a number of ways you could handle this. One way to do it would be to populate your ValueList such that each item has a DataValue (double) and a DisplayText (the char or string to display). That would handle the conversion for you, but you would have to populate the ValueList with every possible value.

        Another way would be to use a DataFilter, but frankly, I'm not sure that would work with a ValueList and it would be a lot more complicated approach.

      • 0
        akram khan
        akram khan answered on Sep 1, 2015 11:00 AM

        Hi,

        Could you please help me with the code. What to replace this code with , 

        ((DataRow[])Ctr.DataSource)[0]["CodeDesc"] = Convert.ToDouble(((DataRow[])Ctr.DataSource)[0]["CodeDesc"]) + 1.


        Regards,

        akram 

      • 0
        akram khan
        akram khan answered on Sep 1, 2015 11:23 AM

        Hi ,

        Adding to that in my case the data value and display member both are number only , i want to display number itself.How could i acheive this. 

        Regards,

        akram 

      • 0
        Mike Saltzman
        Mike Saltzman answered on Sep 1, 2015 2:22 PM

        Hi Akram,

        You need to make sure that the items on the ValueList are the same type as the items in the grid column. So I think it would make more sense to change how you are populating the ValueList, as opposed to changing the data source list. Unless your ValueList is bound and the DataSource you are referring to here is what it's bound to?

        It's very difficult for me to determine what you need to change since I don't know what your app is doing or what these objects are.

        You originally said that the column contain chars – but now you are saying you want numeric values displayed?

      • 0
        akram khan
        akram khan answered on Sep 2, 2015 8:36 AM

        Hi mike,

        The data types of the fields are char only but i am populating a number field in the char field and converting to double +1; my application provides standard char fields only, that i why i am converting to double and adding. 

        ((DataRow[])Ctr.DataSource)[0]["CodeDesc"] = Convert.ToDouble(((DataRow[])Ctr.DataSource)[0]["CodeDesc"]) + 1;

        Hope you understand..

        regards,

        akram 

      • 0
        Mike Saltzman
        Mike Saltzman answered on Sep 2, 2015 3:50 PM

        Hi Akram,

        I did a little test and tried attaching a ValueList that contains integers to a column of ints and another column of doubles and it actually seems to work fine. The grid is able to translate the values without any problem and I get no errors. This is true even when the values in the double column are fractions and do not match anything on the value list. So it seems my initial guess was incorrect.

        So I'm not sure why are you getting this error. Can you post a small sample project that demonstrates the error so we can check it out?

      • 0
        akram khan
        akram khan answered on Sep 15, 2015 1:32 PM

        Hi mike,

        This code has no issues until i add the last piece of code . when i re load the form my combo boxes does not appear , i wrote the below code to see the data in combo boxes, the first line of code is fine (SearchOnUserCodesAdapterShowDialog("DepIdent",cbxDepart);), there is no error upto this point, where as when write the next line (SearchOnUserCodesAdapterShowDialog("RunningNum",cbxRunningNum);) error comes here. 

        private void edvProject_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
        {

        if ((args.Row > -1))
        {
        if (dept_selected == false)
        {
        SearchOnUserCodesAdapterShowDialog("DepIdent",cbxDepart);
        SearchOnUserCodesAdapterShowDialog("RunningNum",cbxRunningNum);
        }

        }

        }

        This is the actual method..

        private void SearchOnUserCodesAdapterShowDialog(string TypeID,Epicor.Mfg.UI.FrameWork.EpiUltraCombo Ctr)

                        {

                                        UserCodesAdapter UserCodesAdapter = new UserCodesAdapter(oTrans);

                                        UserCodesAdapter.BOConnect();

         

                                        bool avail = UserCodesAdapter.GetByID(TypeID);

         

                                        if(avail)

                                        {

                                                        {

                                                                        Ctr.ValueMember = "CodeID";

                                                                       

                                                                        if(TypeID == "RunningNum")

                                                                        {

                                                                        Ctr.ValueMember = "CodeDesc";

                                                                        string str1 ="";

                                                                                        DataRow row = this.edvProject.CurrentDataRow;

                                                                                        if(row!=null)

                                                                                        str1= row["ShortChar01"].ToString();

                                                                                        Ctr.DataSource = UserCodesAdapter.UserCodesData.UDCodes.Select("CodeID = '" +  str1 + "'");

         

                                                                                       

                                                                                        if(((DataRow[])Ctr.DataSource).Length>0)

                                                                                        {

                                                                                                       

                                                                                                        ((DataRow[])Ctr.DataSource)[0]["CodeDesc"] = Convert.ToDouble(((DataRow[])Ctr.DataSource)[0]["CodeDesc"]) + 1;

                                                                                                                                                                                        }

                                                                        }

                                                                        else if(TypeID =="DepIdent")

                                                                        {

                                                                                        string str ="";

                                                                                        DataRow row = this.edvProject.CurrentDataRow;

                                                                                                                        if(row!=null)

                                                                                                                        str= row["ShortChar01"].ToString();

                                                                                        Ctr.DataSource = UserCodesAdapter.UserCodesData.UDCodes.Select("Character01 = '" +  str + "'");

                                                                        }

         

                                                                        else                                                       

                                                                                        Ctr.DataSource = UserCodesAdapter.UserCodesData.UDCodes;

         

         

                                                                        Ctr.DisplayMember = "CodeDesc";

                                                                        string[] fields = new string[] {"CodeDesc"};

                                                                        Ctr.SetColumnFilter(fields);

         

                                                        }

                                        }

                                        UserCodesAdapter.Dispose();

                                       

                        }

        please suggest . 

        Regards,

        Akram 

      • 0
        Mike Saltzman
        Mike Saltzman answered on Sep 15, 2015 3:23 PM

        Hi Akram,

        I'm afraid you lost me. What is "the last piece of code" you refer to here? What do you mean by "when i re load the form my combo boxes does not appear"?

        It sounds like you are saying the exception occurs inside SearchOnUserCodesAdapterShowDialog when you call it the second time. Does that mean it doesn't happen if you comment out the first call? I suspect not – the error probably has nothing to do with the number of times the method is called. More likely, it's the values in the cbxRunningNum object and their types that are causing an issue.

        Exactly what line of code within SearchOnUserCodesAdapterShowDialog does the error occur on? Whatever line of code it is, you need to take a close look at that line and see what the values are and in particular, what Types you are using.

      • 0
        akram khan
        akram khan answered on Sep 16, 2015 5:47 AM

        Hi Mike,

        Last piece of code refers to "SearchOnUserCodesAdapterShowDialog("RunningNum",cbxRunningNum);" line. 

        when i re load the form the data in the combo boxes (field ) does not appear. 

        When i create a fresh entry everything is normal, data appears in the combo boxes. when i re load the form with same projectid , data in combo boxes does not appear. so wrote below code. When  i comment "SearchOnUserCodesAdapterShowDialog("RunningNum",cbxRunningNum);" error does not appear. for "SearchOnUserCodesAdapterShowDialog("DepIdent",cbxDepart);" data apears after form reload also. 

        private void edvProject_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
        {

        if ((args.Row > -1))
        {
        if (dept_selected == false)
        {
        SearchOnUserCodesAdapterShowDialog("DepIdent",cbxDepart);
        SearchOnUserCodesAdapterShowDialog("RunningNum",cbxRunningNum);
        }

        }

        Regards,

        akram

      • 0
        Mike Saltzman
        Mike Saltzman answered on Sep 16, 2015 2:26 PM

        Hi Akram,

        Okay, so as I thought, the problem is specific to cbxRunningNum. There must be something in that object which is causing you to load values into the Combo with incompatible data types.

        I still don't know what you mean by "a fresh entry" or what you mean when you talk about "re load the form". I don't know enough about your application for those to mean anything to me. But as I said, if you can duplicate the exception in a small sample project, I'd be happy to take a look and tell you exactly what's happening.

      • 0
        akram khan
        akram khan answered on Sep 17, 2015 5:48 AM

        Hi Mike,

        Fresh entry means when i save a record in the form , system does not throw any error and i can see all the data in combo boxes. when i close and open the form and select the record which entered, then this error appears. 

        Regards,

        akram

      • 0
        Mike Saltzman
        Mike Saltzman answered on Sep 17, 2015 2:11 PM

        Okay. I'm not sure how that helps solve the issue, though. Maybe something is happening when you close the form – like the object you are using to populate the ValueList has been disposed and so it's contents no longer match the data types you need. I really can't guess why that's happening without a sample to debug.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
akram khan
Favorites
0
Replies
18
Created On
Sep 17, 2015
Last Post
11 years, 1 month ago

Suggested Discussions

Created by

Created on

Sep 17, 2015 2:11 PM

Last activity on

Feb 19, 2026 7:37 AM