Bhoopathi

"Be Somebody Nobody Thought You could Be"

Thursday, July 28

Bind CRM Data to GridView on ASP.NET Page - MS DYNAMICS CRM

//*********** Bind Data to GridView ************//

string fetch = @"   <fetch mapping="logical">
<entity name="card_contactdetails">
<attribute name="card_contactdetailsid"/>
<attribute name="card_firstname"/>
<attribute name="card_lastname"/>
<attribute name="card_ssn"/>
<attribute name="card_state"/>
<attribute name="card_dateofbirth"/>
</entity>
</fetch>";

string result = service.Fetch(fetch);

XmlDocument doc = new XmlDocument();
doc.LoadXml(result);
doc.DocumentElement.Attributes.RemoveAll();

StringReader sr = new StringReader(doc.OuterXml);
DataSet ds = new DataSet();
ds.ReadXml(sr);

GridView1.DataSource = ds;
GridView1.DataBind();