Export to Word Format
Private Sub Word_Export()
Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.doc")
Response.Charset = ""
Response.ContentType = "application/vnd.ms-word "
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
GridView1.AllowPaging = False
GridView1.DataBind()
GridView1.RenderControl(hw)
Response.Output.Write(sw.ToString())
Response.Flush()
Response.End()
End Sub
Export to Excel Format
Private Sub Excel_Export()
Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
GridView1.AllowPaging = False
GridView1.DataBind()
For i As Integer = 0 To GridView1.Rows.Count - 1
Dim row As GridViewRow = GridView1.Rows(i)
'Apply text style to each Row
row.Attributes.Add("class", "textmode")
Next
GridView1.RenderControl(hw)
'style to format numbers to string
Dim style As String = ""
Response.Write(style)
Response.Output.Write(sw.ToString())
Response.Flush()
Response.End()
End Sub
Export to PDF Format
Private Sub PDF_Export()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition","attachment;filename=GridViewExport.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
GridView1.AllowPaging = False
GridView1.DataBind()
GridView1.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.End()
End Sub
It's all about Knowledge blog is a Pakistan’s leading Blog offering new techniques, logic, ready made solutions and tools to developers, students, professionals or IT personnel in order to increase their productivity, skills, knowledge. Keep updated and sharpen with new controls, applications, gadgets and tool. This blog also offers free stuff like free e-books, free download able codes, videos, gadgets, controls, tools and consultation.
Tuesday, June 22, 2010
Tuesday, March 16, 2010
How to Catch Unhandled Exceptions in ASP.NET Using Global.asax
Most of the time asp.net developers faces some exceptions in their applications / websites which came in some exceptional and rare cases. To handle them, we will do something new by using global.asax
Also add a new class file under the App_Code folder. In my case, my file name is Myglobal.vb, inherit this class file to HttpApplication.
Now, open the file and select the page event Error in MyGlobal.vb class file and write your code to handle the exception whether you want to log the error or redirect to the customized error page or whatever do you want, it is upto you.
Now add a global.asax file into your project, make sure the Application_OnError event should be written in global.asax file.
Open the file and add a page directive into global.asax like this i.e.
<%@ Application Language="VB" Inherits="MyGlobal" %>
MyGlobal is the name of my class file which i added into App_Code folder earlier.
Test your code.
Also add a new class file under the App_Code folder. In my case, my file name is Myglobal.vb, inherit this class file to HttpApplication.
Now, open the file and select the page event Error in MyGlobal.vb class file and write your code to handle the exception whether you want to log the error or redirect to the customized error page or whatever do you want, it is upto you.
Now add a global.asax file into your project, make sure the Application_OnError event should be written in global.asax file.
Open the file and add a page directive into global.asax like this i.e.
<%@ Application Language="VB" Inherits="MyGlobal" %>
MyGlobal is the name of my class file which i added into App_Code folder earlier.
Test your code.
Tuesday, February 23, 2010
AJAX rating control using in Gridview
While browsing for answers through various ASP.NET blogs and forums, I often come across certain topics which repeat in one way or another.
This article is an exercise which answers some common GridView
questions. In particular, here I am dealing with:
- MS Access database connectivity.
- MS AjaxControlToolkit's
Rating
extender, which is put on every row allowing the user to rate each row in real time. In other words, as soon as the user rates the row (chooses the number of stars), an asynchronous (AJAX) call to the server is made and the database is updated. - Data bound dropdownlists in each
GridView
row. Each row has a supplier, which is displayed in a dropdown list in order to facilitate record modification. - JavaScript client-side row manipulation. In particular, on checkbox click, the Product textbox is locked/unlocked.
Click here for details ....
Sorting gridview bound with datatable
Protected Sub gvSorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs)
dtData = CType(Session("Data"), DataTable)
Dim dv As DataView = dtData.DefaultView
Dim sortdirection As String
If ViewState("direction") <> "" Then
sortdirection = ViewState("direction")
If sortdirection = "asc" Then
sortdirection = "desc"
Else
sortdirection = "asc"
End If
Else
sortdirection = "asc"
End If
dv.Sort = e.SortExpression + " " + sortdirection
dtData = dv.ToTable
ViewState("direction") = sd
gvwList.DataSource = dtData
gvwList.DataBind()
End Sub
Sunday, January 31, 2010
TinyMCE - Javascript WYSIWYG Editor
TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances. TinyMCE is very easy to integrate into other Content Management Systems.



Friday, September 18, 2009
ASP.NET Dynamic Data
Dynamic Data Road Map
The ASP.NET Dynamic Data Preview 4 Refresh is a new release of Dynamic Data based on some of the early bits we are working on for the next release of the framework. This preview release runs on .NET 3.5 SP1 / VS 2008 SP1. The final version will ship with .NET 4.0 and VS 2010.
This preview shows some of the areas in which we are expanding Dynamic Data:
ASP.NET Dynamic Data MVC Preview contains a preview release of Dynamic Data MVC. This contains samples of how Dynamic Data support may be added to future releases of MVC.
ASP.NET Dynamic Data 4.0 Preview 4 Refresh
Refreshed 6/26
- DomainDataSource had errors updating foreign keys
- Cannot edit many to many relationship with table per type inheritance
- Better exception handling
The ASP.NET Dynamic Data Preview 4 Refresh is a new release of Dynamic Data based on some of the early bits we are working on for the next release of the framework. This preview release runs on .NET 3.5 SP1 / VS 2008 SP1. The final version will ship with .NET 4.0 and VS 2010.
This preview shows some of the areas in which we are expanding Dynamic Data:
- A new QueryExtender control, contained in the sample projects to simplify common data filtering operations. It supports a rich ASP.NET declarative query syntax that makes it easy to do things like search data for text or have filters based on ranges.
- A new Dynamic Data filter model that enables the developers to apply templates to pages just like field templates (including user defined filters).
- Support for inheritance in Entity Framework and Linq to SQL.
- Support for many to many relationships in Entity Framework.
- New Entity Templates which allow fine control over how an object is displayed and edited.
- Attributes for controlling the filters appearance and order.
- A DomainDataSource control that uses a data provider model which enables the developers to build their own custom business logic.
- A datasource control for ADO.NET Data Services that works with ASP.NET and an ADO.NET Data Service Provider for Dynamic Data.
- Starter templates for building new applications with the bits for DomainService, Entity Framework and Linq to SQL.
- Simple Dynamic Data for adding field templates, validation, and entity template support to existing ASP.NET data driven pages.
Download: ASP.NET Dynamic Data Preview 4 Refresh
This also contains the Dynamic Data Futures project which contains some things we the team is considering for future releases of Dynamic Data.ASP.NET Dynamic Data MVC Preview contains a preview release of Dynamic Data MVC. This contains samples of how Dynamic Data support may be added to future releases of MVC.
Friday, September 11, 2009
Take Control of your Web Site
Beezilla CMS website builder is a simple and powerful website content management system (CMS). With Beezilla CMS website builder you can easily create your website on your own.
Creating your website is simple and quick. Choose a website design from our template library or create your own custom template. Add pages to your website with a click of a button. Save some time and create your content using our visual elements library.
Beezilla’s CMS interface is simple, fast and easy to use. Our technology is based on leading web technologies: Apache, PHP, MySQL and ExtJS.
No more delays, no more expensive maintenance cost You can take control of your web site NOW. It's Free!!!
Click here for details .......
Creating your website is simple and quick. Choose a website design from our template library or create your own custom template. Add pages to your website with a click of a button. Save some time and create your content using our visual elements library.
Beezilla’s CMS interface is simple, fast and easy to use. Our technology is based on leading web technologies: Apache, PHP, MySQL and ExtJS.
No more delays, no more expensive maintenance cost You can take control of your web site NOW. It's Free!!!
Click here for details .......
Saturday, September 5, 2009
How To Create MultiColum Dropdownlist using DropDownExtender Control
In this programming field a developer always facing a new requirement, need from their clients and as per the requirement new controls, tips and techniques developed.
Today, i am here to find out that how can we create a multi coloumn dropdown in asp.net
Visit the following link .....
Today, i am here to find out that how can we create a multi coloumn dropdown in asp.net
Visit the following link .....
AJAX CascadingDropdown Control SQL DataBinding
AJAX CascadingDropdown extender control provides the functionality to load the data in ASP.Net dropdown list controls using AJAX based web service methods. AJAX CascadingDropdown extender works with 2 or more Dropdownlist controls that enable you to load the primary data in first dropdown and further it populates the second Dropdown list control dynamically with related data on selected index change event of first dropdownlist.
All this functionality performs without refreshing the ASP.Net web page. In this sample we have used the Northwind SQL Database to load the category names in first Dropdownlist control that will populate the related products into the second dropdownlist control accroding to the category name selected.
Download the sample code .......
Click here for details .......
All this functionality performs without refreshing the ASP.Net web page. In this sample we have used the Northwind SQL Database to load the category names in first Dropdownlist control that will populate the related products into the second dropdownlist control accroding to the category name selected.
Download the sample code .......
Click here for details .......
Sunday, August 16, 2009
Flash Control for ASP.NET
FlashControl is an ASP.NET server control which allow you to add swf Flash movies or Flex in your ASP.NET projects. As any WebControl, you can add FlashControl in Visual Studio Toolbox, and just drag and drop it in your ASP.NET web pages ! It is now compatible with ASP.NET AJAX!


Click here for details ......
Click here for details ......
Subscribe to:
Posts (Atom)