Hi
I am new to winforms but worked in web applicaion. I have an issue at enduser, but unable to replicate at my end.
There is one text box and three search buttons. ( Searchy by visitorname, by ID, by company). when user enters characters in texbox, datagrid view shows the records matching the entered string. internally there is method which will cross check whether entered character is within ASCII code 0-256
Issue is :
when clikced on search by company name , a pop up window comes, saying inputstring was not in correct format.
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Convert.ToInt32 (String value)
at grt.utility.CharactorToLetter.GetOneIndex (String OneIndexTxt)
at grt.utility.CharactorToLetter.IndexCode (String IndexTxt)
at grt.FrmVTRExpToday.tbSearchContent_TextChanged (Object sender, EventArgs e)
at System.Windows.Forms.Control.OnTextChanged(EventArgs e)
at System.Windows.Forms.TextBoxBase.OnTextChanged(EventArgs e)
at System.Windows.Forms.TextBoxBase.WmReflectCommand(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
code snippet roughly:
tbSearchContent_TextChanged(Object sender, EventArgs e)
{
string letters = this.charactertoletter.IndexCode(enteredstring); // charactertoletter is another cs page where the IndexCode methos lies
}
...................
public String IndexCode(String IndexTxt)
{
String _Temp = null;
for (int i = 0; i < IndexTxt.Length; i++)
_Temp = _Temp + GetOneIndex(IndexTxt.Substring(i, 1));
return _Temp;
}
private String GetOneIndex(String OneIndexTxt)
{
if (Convert.ToChar(OneIndexTxt) >= 0 && Convert.ToChar(OneIndexTxt) < 256)
return OneIndexTxt;
}
First two search buttons are working fine. Can any one help me on this issue.