dfdg Lhs

dfdg Lhs

  • 1.9k
  • 2
  • 838

HOW TO GET LIST TYPE VALUE IN TEXTBOX IN SILVERLIGHT

Oct 19 2015 3:11 AM
HOW TO GET LIST TYPE VALUE IN TEXTBOX IN SILVERLIGHT ??
 
DEAR ALL,
 
  I WANT TO DISPLAY A EMP NAME FROM DB TO TEXTBOX IN SILVERLIGHT. SEE BELOW MY CODE.
 
//################################################################################################################ 
private void button1_Click(object sender, RoutedEventArgs e) 
{
ServiceReference1.Service1Client conenction = new ServiceReference1.Service1Client();
conenction.GetEmployeeCompleted += new EventHandler<ServiceReference1.GetEmployeeCompletedEventArgs>(GetAllEmployee);
conenction.GetEmployeeAsync();
 
//########################################  PROBLEM RAISING AREA / QUESTION AREA ################################
 
void GetAllEmployee(object sender, ServiceReference1.GetEmployeeCompletedEventArgs e)
{
DataGridview1.ItemsSource = e.Result.ToList();       // THIS LINE WORKING EXCELLENT TO DISPLAY IN GRIDVIEW
txt_empname.Text = e.Result.ToString();  // THIS LINE IS NOT DISPLAY DATA IN TEXTBOX. //THIS IS DISPLAYING [SILVERLIGHTAPP1.SERVICE REFERENCE1.EMPLOYEE] IN THE EMPTEXTBOX.
//MessageBox.Show(txt_empname.Text);
}
//##################  MY SERVICE CODE WORKING HERE WORKING FINE ###############################################
public class Service1
{
string CONENCTIONSTRING = System.Configuration.ConfigurationManager.ConnectionStrings["SWE"].ConnectionString;
[OperationContract]
public List<Employee> GetEmployee()
{
// Employee employee = new Employee();
List<Employee> employee = new List<Employee>();
using (SqlConnection con = new SqlConnection(CONENCTIONSTRING))
{
using (SqlCommand CMD = new SqlCommand())
{
CMD.Connection = con;
CMD.CommandText = "select EmpName from Employee where EmpNo=101";
CMD.CommandTimeout = 600;
con.Open();
SqlDataReader READER = CMD.ExecuteReader();
while (READER.Read())
{
Employee EMP = new Employee();
// EMP.EmpNo = Convert.ToInt32(READER[0].ToString());
EMP.EmpNme = READER[0].ToString();
//EMP.EmpAddres = READER[2].ToString();
//EMP.EmpSalary = Convert.ToInt32(READER[3].ToString());
//EMP.EmpEducation = Convert.ToInt32(READER[4].ToString());
employee.Add(EMP);
}
}
}
return employee.ToList();
}
 
//###########################################  END OF SERVICE CODE HERE  ################################################### 
 
   

Answers (1)