DATAGRID TO EXCEL
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
DATAGRID TO WORD DOC
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.doc");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.word";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
TO CONVERT DATAGRID DATA TO EXCEL & WORD DOC
Thursday, July 19, 2007 | 0 Comments
CONFIRMATION OF DELETE BUTTON IN GRID
private void grd_ItemDataBound(object sender,System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.FindControl("Delete") != null)
{
((LinkButton) e.Item.FindControl("Delete")).Attributes.Add("onClick", "return confirm('Are you sure to delete this item?');");;
}
}
findcontrol() method searches the current naming container for a server control with the specified id parameter.using the findcontrol we find the delete link button and give the confirmation box using javascript when the button in the grid is clicked.
Thursday, July 19, 2007 | 0 Comments
Changing Link Text
<html>
<head>
<script>
function ChangeLinkText(obj)
{
var element = document.getElementById(obj);
element.innerHTML = 'Link Text Changed';
}
</script>
</head>
<body>
<a id="Link" href="javascript:ChangeLinkText('Link');">Click to Change
Link Text</a><br>
<a id="OrdinaryLink" href="http://geeksdotnetcorner.blogspot.com"> Enter
GeeksDotNetCorner </a>
</body>
<html>
Monday, July 16, 2007 | 0 Comments