I am getting data from database using wcf service, At the time of displaying data in browser not displaying correct format this is my code [DataContract] public class StopUpdate { [DataMember] public string STOP_SEQUENCE { get; set; } [DataMember] public string STOPTYPE { get; set; } [DataMember] public string DUE_TIMEZONE { get; set; } [DataMember] public string DUE { get; set; } [DataMember] public string ENDDUE { get; set; } [DataMember] public string ACTUALARRIVAL_TIMEZONE { get; set; } [DataMember] public string ACTUALARRIVAL { get; set; } [DataMember] public string ACTUALDEPART_TIMEZONE { get; set; } [DataMember] public string ACTUALDEPART { get; set; } } [DataContract] public class CompanyDefinedField { [DataMember] public string TRIPNUM { get; set; } [DataMember] public string DLULOAD { get; set; } [DataMember] public string ND { get; set; } [DataMember] public string LOADING_CARRIER { get; set; } } ///////////////// [DataContract] public class Status { [DataMember] public string ROUP_ID {get;set;} [DataMember] public System.DateTime PROCESSED_DATE{get;set;} [DataMember] public string PST_STATUS_TYPE{get;set;} [DataMember] public int LOADID{get;set;} [DataMember] public string SHIPPER_REF{get;set;} [DataMember] public string TENDERID{get;set;} [DataMember] public string LOADREFERENCE{get;set;} [DataMember] public string TRAILERNUM{get;set;} [DataMember] public string DRIVERNAME{get;set;} [DataMember] public string VEHICLENUMBER{get;set;} [DataMember] public string FORCECLOSE{get;set;} [DataMember] public string ENROUTE{get;set;} [DataMember] public string WSHOLDSTATUS{get;set;} [DataMember] public string PRIORITY{get;set;} [DataMember] public string COMMENTS{get;set;} [DataMember] public string SHIPPINGSTATUSCODESET{get;set;} [DataMember] public string TRIPNUM{get;set;} [DataMember] public string DLULOAD{get;set;} [DataMember] public string ND{get;set;} [DataMember] public string LOADING_CARRIER{get;set;} [DataMember] public List<StopUpdate> stopUpdates; [DataMember] public List<CompanyDefinedField> CompanyDefinedFields; } Interface methos: [WebGet(ResponseFormat = WebMessageFormat.Xml)] [OperationContract] List<Status> Allstatus(int loadid); Implementation: public List<Status> AllLoadstatus(int loadid) { List<Status> lists = new List<Status>(); / SqlConnection con = new SqlConnection(@"Data Source=ASHDEVBTS-1;Initial Catalog=Sampath;Integrated Security=True"); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Clear(); cmd.CommandText = "Select_sta"; SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Status sh = new Status(); sh.LEAN_LOAD_ID = Convert.ToInt32(dr["LEAN_LOAD_ID"]); sh.PST_STATUS_TYPE = Convert.ToString(dr["PST_STATUS_TYPE"]); sh.TRIPNUM = Convert.ToString(dr["TRIPNUM"]); sh.DLULOAD = Convert.ToString(dr["DLULOAD"]); sh.ND = Convert.ToString(dr["ND"]); sh.STOP_SEQUENCE = Convert.ToString(dr["STOP_SEQUENCE"]); sh.CMP_ID = Convert.ToString(dr["CMP_ID"]); sh.DUE_DATE_START = Convert.ToDateTime(dr["DUE_DATE_START"]); sh.DUE_DATE_END = Convert.ToDateTime(dr["DUE_DATE_END"]); sh.PLAN_DEST_DRIVER_ID = Convert.ToString(dr["PLAN_DEST_DRIVER_ID"]); sh.PLAN_DEST_TRL_DISPLAY = Convert.ToString(dr["PLAN_DEST_TRL_DISPLAY"]); var data = new Status(){LoadID=sp.LoadID,, stopUpdates = new List<StopUpdate>{new StopUpdate(){STOP_SEQUENCE=st.STOP_SEQUENCE,STOPTYPE=st.STOPTYPE,DUE_TIMEZONE=st.DUE_TIMEZONE, DUE=st.DUE,ENDDUE=st.ENDDUE,ACTUALARRIVAL_TIMEZONE=st.ACTUALARRIVAL_TIMEZONE,ACTUALARRIVAL=st.ACTUALARRIVAL, ACTUALDEPART_TIMEZONE=st.ACTUALDEPART_TIMEZONE,ACTUALDEPART=st.ACTUALDEPART} } }; lists.Add(data); } return lists.ToList(); } I am running getting output like this code,i am getting output like this,matching one Loadid value <?xml version="1.0"?> -<ArrayOfStatus xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LoadPlan"> -<Status><LOADID>36546186</LOADID><SHIPPER_REF>AFAR </SHIPPER_REF> -<StopUpdate> <ACTUALDEPART>Sales<ACTUALDEPART/><ACTUALDEPART_TIMEZONE>12-03-14<ACTUALDEPART_TIMEZONE/><STOPTYPE>P</STOPTYPE><STOP_SEQUENCE>1</STOP_SEQUENCE></StopUpdate></stopUpdates></Status> in my table loadid same value in two rows,in that situation,i want to display data like this,
<?xml version="1.0"?> -<ArrayOfStatus xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LoadPlan"> -<Status><LOADID>36546186</LOADID><SHIPPER_REF>AFAR </SHIPPER_REF> -<StopUpdate> <ACTUALDEPART>Sales<ACTUALDEPART/><ACTUALDEPART_TIMEZONE>12-03-14<ACTUALDEPART_TIMEZONE/><STOPTYPE>P</STOPTYPE><STOP_SEQUENCE>1</STOP_SEQUENCE></StopUpdate> - <StopUpdate> <ACTUALDEPART>dept<ACTUALDEPART/><ACTUALDEPART_TIMEZONE>11-07-14<ACTUALDEPART_TIMEZONE/><STOPTYPE>d</STOPTYPE><STOP_SEQUENCE>2</STOP_SEQUENCE></StopUpdate></stopUpdates></Status>
The condition how many times execute based on LoadId that many times get values and display in StopUpdate vales can you please give me the idea about that one
anilbabu