Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code......... on find button click event

C#
private void btnfind_Click(object sender, EventArgs e)
       {
           try
           {
               rec = ds.Tables[0].Select("Enm.Id=" + txtemp.Text)[0];
               txtname.Text = rec[1].ToString();
               txtdesg.Text = rec[2].ToString();
               txtdoj.Text = rec[3].ToString();
               txtsal.Text = rec[4].ToString();
               txtdept.Text = rec[5].ToString();
               cmdupdate.Enabled = true;
           }
           catch
           {
               MessageBox.Show("Record not found");
           }
Posted

1 solution

For the Select method of DataTable class, the Text in the condition of FilterExpression shall be enclosed in single quotes. Hence, put single quotes in the select method as shown below

C#
rec = ds.Tables[0].Select("Enm.Id='" + txtemp.Text  + "'")[0];


You may vote and accept the solution if your problem is solved, otherwise please post your queries
 
Share this answer
 
v3
Comments
rockpune 8-Mar-12 2:24am    
thanx alot my dear friend
ProEnggSoft 8-Mar-12 2:29am    
Happy to know that it served your purpose.

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