Question : asp.net 2010

Hello

Ive have this that populates a lstbox from a dataset it has 5 items in it and when it compares a textbox value thats in the lstbox it will flag it else it will say not there, but when i enter the 2nd textbox value to compare it says its not there so i re-enter and it says it is there, it only happens on the 2nd value each time every other value 1,2(doesnt find, renter and does find),3,4,5 are fine.

here is code.....

if (dsWoSerials.Tables.Count > 0)
            {
                for (int j = 0; j < dsWoSerials.Tables[0].Rows.Count; j++)
                {
                    DataRow row = dsWoSerials.Tables[0].Rows[j];
                    lstbSerials.Items.Add(row[0].ToString());
                    ListItem lstitem = lstbSerials.Items.FindByText(txtSerialNumberScan.Text);
                    if (lstitem != null)
                    {
                        AddToTree();
                        break;
                    }
                    else
                    {
                        fs_userfeedback.InnerHtml = "<p><h1> No Serial Exists at LBLPACK1!</h1></p>";
                        fs_userfeedback.Style.Add("background-color", "red");
                        txtSerialNumberScan.Text = "";
                        txtSerialNumberScan.Focus();
                    }
                }
            }

Answer : asp.net 2010

try"
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
if (dsWoSerials.Tables.Count > 0)
            {
                var found = false;

                foreach (DataRow row in dsWoSerials.Tables[0].Rows)
                {
                    lstbSerials.Items.Add(row.ItemArray[0].ToString());
                    ListItem lstitem = lstbSerials.Items.FindByText(txtSerialNumberScan.Text);
                    if (lstitem != null)
                    {
                        found = true;
                        AddToTree();
                        break;
                    }
                }

                if (!found)
                {
                    fs_userfeedback.InnerHtml = "<p><h1> No Serial Exists at LBLPACK1!</h1></p>";
                    fs_userfeedback.Style.Add("background-color", "red");
                    txtSerialNumberScan.Text = "";
                    txtSerialNumberScan.Focus();
                }
            }
Random Solutions  
 
programming4us programming4us