Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everyone I need to send large data from WFC to consumer(in my application i am using windows phone smart device) through JSON.

the code i am using is,

[ServiceContract]
   public interface ISampleService
   {
       [OperationContract]
       [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.WrappedRequest, UriTemplate = "GetEmployeeData/{userName}")]
       DataSet GetEmployeeData(string userName);

    }


SQL
public DataSet GetEmployeeData(string userName)
       {

           DataSet ds = dbServices.GetEmployeeData(userName);
           if (ds.Tables[0].Rows.Count > 0)
           {
               return ds;
           }
           else
           return null;
       }


and i receive the data in consumer(windows smart device app) as

HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url + "GetEmployeeData" + "/" + "manikandan");
                webrequest.Method = "POST";
                webrequest.ContentType = "application/xml";
                webrequest.ContentLength = 0;
                Stream stream = webrequest.GetRequestStream();
                stream.Close();
                string result;
                using (WebResponse response = webrequest.GetResponse())
                {
                    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    {
                        result = reader.ReadToEnd();
                    }
                }
                DataSet ds = new DataSet();
                XmlElement exelement;
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(result);
                exelement = doc.DocumentElement;
                 if (exelement != null)
                 {  
                     XmlNodeReader nodereader = new XmlNodeReader(exelement);
                     ds.ReadXml(nodereader, XmlReadMode.Auto);
                 }
                 lblCount.Text = ds.Tables[0].Rows.Count.ToString();
                 lblds.Text = ds.Tables[0].Rows[0][1].ToString();
                 dataGrid1.DataSource = ds;

when i did all the above the datagrid in the windows mobile is not loaded with the data.
I checked the dataset, by
string val = ds.Tables[0].Rows[0][1].ToString();


it receives the data. now can anybody tell me how to bind my ds to the datagrid in windows smartdevice mobile application.
Thanks in advance.
Posted
Comments
Try like below...

dataGrid1.DataSource = ds.Tables[0];
Manikandan Sekar 18-Jul-13 2:10am    
Thanks Tadit Dash and Dheeraj_Gupta for your valuable replies. I did it by yesterday itself.But the thing to note here is, as i am using WCF Service it must need to support in all platforms right. For example suppose if am developing android app the service should support that also. For that you experts give me a suggestion. Any way its working fine in windows mobile app now.

1 solution

SQL
Use Followoing line of code.


datagrid1.DataSource = ds.Tables[0];


Mark as answer if it suffice your answer...
 
Share this answer
 

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