Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Purushottam Dwivedi on Nov 30, 2008 21:39
open dhtmlx forum
DhtmlxGrid PLEASE SEND ME URGENT !!!!!!!!!!!!!!!!!!!!! LOAD XML OR INCORRECT XML ERROR

Please Rectify this code i want to show the run time generated xml file in the dhtmlxgrid

This is my daldatalink.cs file which is in app_code

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Xml;
using System.Collections.Specialized;
using System.Collections;
using PIInfosoft.Framework.Data;
using Microsoft.Xml.XQuery;
using System.IO;
using System.Data.SqlClient;

/// <summary>
/// Summary description for dalDataLink
/// </summary>
///
namespace PI.Dal.Package
{
public class dalDataLink
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServer"].ToString());

protected XmlDocument xmlDoc = null;
//protected IDbConnection conn = null;
protected String tag = "";
protected string strICode = "";
protected string strPageName = "";
public dalDataLink( String xmlFile,string pstrICode)
{
this.xmlDoc = new XmlDocument();
this.xmlDoc.Load(xmlFile);
strICode = pstrICode;
strPageName = "Package";
}
~dalDataLink()
{ }


private String PrintXMLHeader()
{
return this.PrintXMLHeader("data", "");
}
private String PrintXMLHeader(String tag, String add)
{
this.tag = tag;
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><" + tag + " " + add + ">";

}
private String PrintXMLFooter()
{
return "</" + this.tag + ">";
}
/// <summary>
///
/// </summary>
/// <param name="action"></param>
/// <param name="sid"></param>
/// <param name="tid"></param>
/// <returns></returns>
private String PrintAction(String action, String sid, String tid)
{
return "<action type='" + action + "' sid='" + sid + "' tid='" + tid + "'/>";
}





public String getXML()
{
String res = "";
String type = (xmlDoc.DocumentElement.Attributes["type"] != null) ? xmlDoc.DocumentElement.Attributes["type"].Value : "";
switch (type)
{
case "tree":
break;
default:
if(strPageName=="Package")
{
res += this.PrintXMLHeader("rows", "");
res += "<head> " +
" <column width='50' type='ro' align='center' color='#d5f1ff' >Sr No.</column> " +
" <column width='50' type='ro' align='left' >vcItineraryCode</column> " +
" <column width='100' type='ro' align='center' >From Date</column> " +
" <column width='100' type='ro' align='center' > From Place</column> " +
" <column width='100' type='ro' align='left' >To Place </column> " +
" <column width='100' type='ro' align='left' >Mode </column> " +
" <column width='100' type='ro' align='left'> OverNight</column> " +
" <column width='80' type='ro' align='center' >To Date</column> " +
" <column width='150' type='ro' align='left' >stayNight</column> " +
" <column width='150' type='ro' align='left' >From PlaceCode</column> " +
" <column width='150' type='ro' align='left' >To PlaceCode</column> " +
" <settings> " +
" <colwidth>px</colwidth> " +
" </settings> " +
" </head> ";
res += this.GetXmlGrid();
}
break;
}
res += this.PrintXMLFooter();
//conn.Close();
return res;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
private String GetXmlGrid()
{
String res = "";
String where = xmlDoc.GetElementsByTagName("where")[0].InnerText;
if (strPageName == "Package")
{

String sql = "SELECT * FROM " + xmlDoc.GetElementsByTagName("table")[0].Attributes["name"].Value;
if (where != "" && strICode != "")
sql += " WHERE " + where + "='" + strICode.Trim() + "' order by inSrNo";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.Connection.Open();
IDataReader r = cmd.ExecuteReader();
while (r.Read())
{
res += "<row id=\"" + r[xmlDoc.GetElementsByTagName("key")[0].Attributes["name"].Value] + "\">";

foreach (XmlElement param in xmlDoc.GetElementsByTagName("param"))
{
if (param.Attributes["name"].Value == "inSrNo")
{
res += "<cell >" + r[0] + "</cell>";
}
else
{
res += "<cell>" + r[param.Attributes["name"].Value] + "</cell>";
}
}

res += "</row>";
}

cmd.Connection.Close();
return res;
}
else{return res;}

}



}
}




This is my bllpackage.cs file



using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using PI.Dal.Package;
/// <summary>
/// Summary description for BllPackage
/// </summary>
namespace PI.Bll.package
{
public class BllPackage
{
protected String strFileName = "";
protected string strPICode = "";
protected string strPageName = string.Empty;
public BllPackage(String xmlFile, string pstrICode)
{
this.strFileName = xmlFile;
this.strPageName = "Package";
strPICode = pstrICode;
}
~BllPackage()
{
}


public String getXML()
{

PI.Dal.Package.dalDataLink objdaldatalink = new PI.Dal.Package.dalDataLink(strFileName, strPICode);
String res = objdaldatalink.getXML();
return res;
}
}
}



this is my package




<script language="javascript" type="text/javascript" src="scripts/dhtmlXGrid.js"></script>
<script language="javascript" type="text/javascript" src="scripts/dhtmlXCommon.js"></script>
<script language="javascript" type="text/javascript" src="scripts/dhtmlXGridCell.js"></script>
<script language="javascript" type="text/javascript" src="scripts/dhtmlXDataProcessor.js"></script>
<script language="javascript" type="text/javascript" src="scripts/CommonScript.js"></script>

<div >


<div id="divWait" style="display:none;">
Wait while processing <img src="Images/processing.gif" alt="Processing" title="Processing"/>
</div>
<span style="display:inline;"> Select Package</span>
  <asp:DropDownList ID="ddlPacakageNames" Width="264px" runat="server" AutoPostBack="True" onchange="getddlseletedvalue();" >
<asp:ListItem>Select Package</asp:ListItem>

</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<br />

<div style="color:Red;"><strong>Note :</strong> Do not press F5(Refresh) or Back Button u lost all data</div>
<%--<img src="../Images/spacer.jpg" width="1" height="400" style="float:left" alt="" />--%>
<br />



<div id='gridbox' style="width:100%; height:200px; background-color:White;overflow:hidden;" >
</div>

<br />

<div id="xy" >
<%--<input type="button" id="BtnNext" value="Next...." style="display:inline;"/>
--%>
</div>
<script language="javascript" type="text/javascript">



mygrid = new dhtmlXGridObject('gridbox');
mygrid.imgURL='http://'+location.host+'/t2india/Images/imgs/';

var x="pi-001"
mygrid.loadXML("http://"+location.host+"/t2india/PackageLoadData.aspx?PCode="+ x + "");

     mygrid.init();




when page is loaded then ERROR IS LOADXML ,INCORRECT XML


THIS IS MY XML GENERATION FILE


<?xml version="1.0" encoding="utf-8"?>
<data>
<table name="Puru_ItineraryDetails">
<key name="inpkey">grid_id</key>
<param name="inSrNo">c0</param>
<param name="vcItineraryCode">c1</param>
<param name="dtFromDate">c2</param>
<param name="vcFromPlace">c3</param>
<param name="vcToPlace">c4</param>
<param name="vcMode">c5</param>
<param name="inOverNight">c6</param>
<param name="dtToDate">c7</param>
<param name="inStayingNights">c8</param>
<param name="vcFromPlaceCode">c9</param>
<param name="vcToPlaceCode">c10</param>

<where>vcItineraryCode</where>
</table>
<action>!nativeeditor_status</action>
</data>
Answer posted by Support on Dec 01, 2008 02:26
Please be sure that XML data outputed with correct content type - text/xml
Also, you can use debug version of dhtlmxcommon ( or debug of dataprocessor ) to check exact server side response, which may contain info about some error. 
http://dhtmlx.com/docs/products/kb/index.shtml?cat=search&q=2545&ssr=yes&s=dhtmlxcommon