Get the data from datatable/list, write it in a xml format.
using System.Data.SqlClient;
using System.IO;
using System.Xml;
using System.Text;
protected void Page_Load(object sender, EventArgs e)
{
ReturnProductDetailsCollections();
}
void ReturnProductDetailsCollections()
{
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-60));
PGILib objPGLib = new PGILib();
try
{
int CollectionID;
StringWriter sw = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(sw);
if (Request.QueryString["ProductID"] != null && Request.QueryString["LanguageID"] != null)
{
CollectionID = Convert.ToInt32(Request.QueryString["ProductID"]);
int iLanguageID = Convert.ToInt32(Request.QueryString["LanguageID"]);
string Currentlang = "";
DataTable dtCurrentlang = new DataTable();
dtCurrentlang = objPGLib.Script_GetLanguageName(iLanguageID);
if (dtCurrentlang.Rows.Count > 0)
{
foreach (DataRow dr in dtCurrentlang.Rows)
{
Currentlang = dr["LanguageShortName"].ToString();
}
}
int CategoryID = objPGLib.getCollectionCategoryIDByMarket(iLanguageID);
writer.WriteStartElement("designgallery");
writer.WriteAttributeString("Result", "Success");
DataTable dtProductCollection = new DataTable();
dtProductCollection = objPGLib.Script_GetDesignerCollections(CollectionID,CategoryID);
if (dtProductCollection.Rows.Count > 0)
{
foreach (DataRow dr1 in dtProductCollection.Rows)
{
string strpPath = ConfigurationManager.AppSettings["UploadLocation"].ToString() + dr1["SmallThumbnailPath"].ToString();
writer.WriteStartElement("product");
writer.WriteAttributeString("productid", dr1["ProductID"].ToString());
writer.WriteAttributeString("smallthumbnail", strpPath);
writer.WriteAttributeString("name", dr1["ProductName"].ToString());
writer.WriteAttributeString("designer", dr1["FirstName"].ToString());
writer.WriteEndElement();
}
}
}
else
{
writer.WriteStartElement("designgallery");
writer.WriteAttributeString("Result", "Failure");
}
writer.WriteEndElement();
Response.ContentType = "text/xml";
Response.ContentEncoding = Encoding.UTF8;
Response.Write(sw);
}
catch (Exception ex)
{
AppLogger.LogError("Designer Gallery Product ReturnProductDetailsCollections(based on designerid) " + ex.Message, AppLogger.Severity.Error);
}
}
ஏஞ்சல்
என்னை பற்றி
Google reader
Categories
- .Net (9)
- .Net Crystal Report (1)
- .Net GridView (3)
- Articles (5)
- Log File .Net (1)
- Sharepoint (2)
- Sitefinity 3.7 (3)
- SQL (5)
- Technical Question and Ans (3)
- Validation (1)
- XML (2)
Monday, July 27, 2009
Return XML File
When hearts listen
angel sing.If you seek an angel with an open heart...
You shall always find loved one