Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All ,

I am writing the following code at run time it retrieve the fields from data base but do not assign to the text fields whats wrong with it.

Here is my code .


C#
protected void btnSearch_Click(object sender, EventArgs e)
       {
           int sno=int.Parse(txtStID.Text.ToString());

           ResultDbContext rc = new ResultDbContext();
           TblResult res=rc.TblResults.ToList().Where(x=>
           x.StID==int.Parse(txtStID.Text)).First();


           if ((res.Class == "XI") && (res.SGroup == "Pre-Engineering"))
         {
             txtName.Text = res.SName;
             txtFName.Text = res.FName;
             txtClass.Text = res.Class;
             txtSGroup.Text = res.SGroup;
             txtEng1.Enabled = true;
             txtEng1.Text = res.Eng1.ToString();
             txtUrdu1.Enabled = true;
             txtPhy1.Text = res.Phy1.ToString();
             txtChem1.Enabled = true;
             txtChem1.Text = res.Chem1.ToString();
             txtMath1.Enabled = true;
             txtMath1.Text = res.Math1.ToString();

         }
        }
Posted
Updated 8-Jun-15 20:35pm
v3
Comments
Zafar Sultan 9-Jun-15 2:48am    
Can you put a breakpoint inside the "if" condition and check if you are getting values there?

1 solution

We cannot run your code so there is no way for us to know what is wrong. You are assigning values to the Text property so that part is OK. However, you'll have to debug your own code since we can't run it. Perhaps res.Class does not equal "XI" or perhaps res.SGroup != "Pre-Engineering" or res.SName is blank. There is no way we can know. You have to debug it.
 
Share this answer
 

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