Hello everybody,
[SILVERLIGHT TASK]
I want to display emp_name in the textbox using wcf in silverlight 5.
Below are the codes which is working fine on gridview, but I want display only emp_name in the textbox thats the task.
===============================================
1. MAINPAGE.XAML.CS
private void button1_Click(object sender, RoutedEventArgs e)
{
ServiceReference1.Service1Client conenction = new ServiceReference1.Service1Client();
conenction.GetEmployeeCompleted += new EventHandler<servicereference1.getemployeecompletedeventargs>(GET_EMP_NAME);
conenction.GetEmployeeAsync();
}
void GET_EMP_NAME(object sender, ServiceReference1.GetEmployeeCompletedEventArgs e)
{
ServiceReference1.Employee emp = new ServiceReference1.Employee();
txt_empname.Text=e.Result.ToList().ToString();
DATAGRIDVIEW.ItemSource=e.Result.Tolist();
==================================================
2. MY SERVICE CODE HERE. **This service working fine **
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1
{
string CONENCTIONSTRING = System.Configuration.ConfigurationManager.ConnectionStrings["SWE"].ConnectionString;
[OperationContract]
public List<employee> GetEmployee()
{
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.EmpNme = READER[0].ToString();
employee.Add(EMP);
}
}
}
return employee.ToList();
}
=================================================
3. MY EMPLOYEE CLASS
public class Employee
{
public int EmpNo { get; set; }
public string EmpNme { get; set; }
public string EmpAddres { get; set; }
public int EmpSalary { get; set; }
public int EmpEducation { get; set; }
}
=================================================