Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Designed My Silverlight XMAL Page With AutoComplete Box,Search Button And Data Grid.
Now I Wrote Wcf Service With LinqToSql For getting Related Data from DataBase Table When I Entered Data In AutoComplete Box And Clicked On Search Button then result will be displayed in DataGrid In SilverLight.

For Above Requirement I Wrote Code Like Below:

first i wrote class with properties like,
C#
public class University
   {        public string PUnivId {set;get;}
       public string PUnivName{set;get;}
       public string PUnivAdd{set;get;}
       public string PAICTEgrd{set;get;}
   }

Wcf Service Code:

C#
public class Service1
    {
       [OperationContract]
        public List<University> UniversityList(string sdata)
        {
            var UnivList = new List<University>();
            SwathiClsDataContext obj = new SwathiClsDataContext();
            var s = from i in obj.fg0uv000s.AsEnumerable() where i.UnivID == sdata select i;
         if(s!=null)
            foreach(var dt in s)
            {
                var univ = new University
                {
                    PUnivId=dt.UnivID.ToString(),
                    PUnivName=dt.UnivName.ToString(),
                    PUnivAdd=dt.UnivAdd.ToString(),
                    PAICTEgrd=dt.AICTEgrd.ToString()
                };
               UnivList.Add(univ);
            }
            return UnivList;
        }
    }


After adding wcf service reference in silverlight application,i wrote code using eventhandler like this,

C#
private void btnSearch_Click(object sender, RoutedEventArgs e)
 {
  ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
  client.UniversityListCompleted+=new EventHandler<UniversityListCompletedEventArgs>(client_UniversityListCompleted);
            client.UniversityListAsync(txtAcb.Text);
}
    void client_UniversityListCompleted(object sender, UniversityListCompletedEventArgs e)
    {
            mydatagrid.ItemsSource = e.Result;
   }


my complete code is above,but i didn't get result into datagrid.

Please give me some suggestions to get result.


Thanks,
vijay.
Posted
Updated 21-Jan-12 9:08am
v2
Comments
Jaganathan Bantheswaran 21-Jan-12 22:39pm    
e.Results returns the List?
vijay4mgvrm 22-Jan-12 0:26am    
Yes
vijay4mgvrm 22-Jan-12 0:26am    
I Got Result.......
Jaganathan Bantheswaran 22-Jan-12 23:42pm    
Can you please post the XAML binding section?

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