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,
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:
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,
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.