Tuesday, September 18, 2012

Download as xml attachment using c#

Response.Clear();
Response.ContentType =
"application/xml";
Response.AppendHeader(
"Content-Disposition", "attachment;filename=" + strFileName + ".xml");Response.AppendHeader(
"Content-Length", strXML.Length.ToString());Response.Write(strXML.ToString());
xmlWriter.Close();

HttpContext.Current.ApplicationInstance.CompleteRequest();

Tuesday, September 4, 2012

Comparing with Lamda expression in C#


string str = string.Empty;
                for (int i = 0; i < drCardSetDef.Length; i++)
                {
                     str   = Convert.ToString(drCardSetDef[i]["ids"]);
                    if (!string.IsNullOrEmpty(str ))
                    {
                        if (Array.Find( str  .Split(','), s => s.Equals(drow["IDI"].ToString())) != null)
                        {
                            drCardSetDef[i][" IDI "] = drowHosps["ids"];
                        }
                    }
                }