.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Problems with encoding (UTF-8) when exporting Gridview to CSV

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :ASP.Net

I have a gridview surrounded by buttons adding export functionality to Word, Excel, PDF, CSV/TXT. The code origins from:




and was easily applied. Now, while the first 3 works like a charm, the CSV/TXT exports nicely enough, but the encoding goes *poof* so some - in my case Scandinavian - characters looks anything but Scandinavian. A screenshot on the aforementioned page indicates, that its not my use, but a general problem in this code (found below) I have been experimenting with response.charset and response.contentencoding with no luck. Does anyone here have a clue (or an alternative solution)


Protected Sub btnExportCSV_Click(ByVal sender As Object, ByVal e As EventArgs)
        Response.Buffer = True
        Response.AddHeader("content-disposition", "attachment;filename=TMS-Pro.txt")
        Response.Charset = ""

        Response.ContentType = "application/text"

        GridView1.AllowPaging = False

        Dim sb As New StringBuilder()
        For k As Integer = 0 T

View Complete Post

More Related Resource Links

Gridview Problems


I am filter a gridview based on different criteria that user picks during run.  The problem is that if I only have a few items the header and each row gets really big and might take up most of the screen.  Any ideals how to fix?



Encoding Problems in Razor



On my projects I am using SquisIt Framework and I have the following on page head:


      .Render("~/Styles/FlyOnDreams.FlyOnPages.Core.min.css")) %>

This is working. However when I use Razor view engine I am using the following:


Exporting a gridview into word landscape

Hi,  I have managed to export a gridview into word but is there a way when i export the gridview into Word that Word opens in landscape? Thanks in advance, Jon 

About GridView ...Problems

hi i m new in GridView Control so pLease Help me.... I  use GridView For simple Edit And Delete Data i use through CommandField and i Success... ok so what about all other CheckBoxField,HyperLinkField,ImageField,ButtonField,TemplateField  Field  Help how to use this field and in which events fires so i can get ID of particular row ....     <asp:GridView ID="GV" runat="server" AutoGenerateColumns="False" OnRowEditing="GV_RowEditing" OnRowDeleting="GV_RowDeleting" OnRowCommand="GV_RowCommand" > <Columns> <asp:BoundField DataField="ID" HeaderText="ID" /> <asp:BoundField DataField="DoctorName" HeaderText="DoctorName" /> <asp:BoundField DataField="Designation" HeaderText="Designation" /> <asp:CommandField HeaderText="Edit" ShowEditButton="True" /><asp:CommandField HeaderText="Delete" ShowDeleteButton="True" /> <asp:CheckBoxField /> <asp:HyperLinkField /> <asp:ImageField/> <asp:ButtonField Text="Button" /><asp:TemplateField /> </Columns> </asp:GridView>

problems displaying image in GridView

That's right, it's me again! For the third or fourth time around I'm trying to make this work... I want to display images in a Gridview, but I'm stuck at getting the images to display. The GridView shows only the image ID:s.My images are saved in the database as <Binary Data>. I'm using an aspx page as Image Handler that receives the binary data of the image from the database and writes it to a response stream (at least that's what the tutorial says I'm doing), and the I use an Image Control in Template field on GridView to call the handler. I've been following this tutorial, and also Mudassar Khans prevoius tutorials combined with other tutorials:http://www.aspsnippets.com/Articles/Display-images-from-SQL-Server-Database-in-ASP.Net-GridView-control.aspxThankful for help!Here's my code,Imagehandler: protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["ID"] != null) { string sql = "SELECT ImgData, ImgContType from" + " BildProd where id=@id"; String strConnString = System.Configuration.ConfigurationManager .ConnectionStrings["DBPejganConnectionString1"].ConnectionString; SqlCommand cmd = new SqlCommand(sql); cmd.Parameters.Add("@id", SqlDbType.Int).Value

google Translate Encoding Problems With C#

//Create a Google Translate String To Translate From Google. string Translate(string inputStr, string fromLanguage, string toLanguage) { string url = string.Format("http://translate.google.com/translate_a/t?client=t&text={0}&hl=en&sl={1}&tl={2}&multires=1&pc=0&sc=1", inputStr, fromLanguage, toLanguage); WebClient tmpClient = new WebClient(); tmpClient.Encoding = System.Text.Encoding.UTF8; string result = tmpClient.DownloadString(url); return result; } Now The Problem is If You Pass something like that Translate("Hello","en","ur"); Return String: JSON String But Couldn't Really Get The Write Method to Get ???? ???? Instead Of ? ?? ?? ? { ur: [[["? ?? ?? ?","Hello World",""]],,"en"] }   In Browsers The URL is Showing Correct Returned String. Urdu is unicode Language. The String Return in result is Whole Messed up with ???? ?? ???? something like that. I tried to Convert it in Different Encodings But Not Couldn't get Anythine usefull. How Can I Correct That I Wanted To Further Save It In XML File.

Problems with Gridview display



Hello All,

I have a gridview ...asp 2.0 and VS 2005.

The Gridview has template fields and I am using a Header Templete and an Item Template field.

Within the Item template fields I am using a asp: table and within the table I am using different asp controls to bind data to the gridview

Here is the issue ...I want that each datafield should align with each other eactly i.e. symmetricaly each column wise.

The problem as of now is that as each row of data is displayed in a new table and as a result each column aligns differently.

How can I align the columns with each other?

How is





       <asp:label>  ...<Eval(datafield) </asp:label>




       <asp:label>  ...<Eval(datafield) </asp:label>




Problems in Exporting to Excel 2007


When I export a GridView to Excel 2007 I get an error message:

 The file you are trying to open < > is in a different format than specified by the file extension.  Verify that the file is not corrupted and is from a trusted source before opening the file.  Do you want to open the file now?

 This worked OK with Excel 2003.  I called Microsoft and they told me I was using a non-release version which is not true.  My Office 2007 was downloaded from MSDN in Dec 2006.  I found a reference on the Internet that said this problem would be fixed in the released version but it is not.



gridview binding problems


am new to this forum....

hi i have 3 tables

customerlogin (cus_id)



inputs are customerlogin cust_id and product prod_id

i want to get the output lik this..

if customerlogin cus_id=custprice cust_id and p.prod_id=customerprice prod_id means

output is lik customerprice table priceamt


product table pricceamt

here in my from am giving only one productid and multiple customerid

my store procedure is given below:

if exists(select cp.cust_id,p.PID from CustomerLogin c,Customerprice cp,Productable p
where cp.cust_id=@cust_id And cp.PID=@PID)
--select cp.Productprice from Customerprice cp where cp.cust_id=c.cust_id
select distinct cp.Productprice,'auto' as Pricetype,c.cust_name,c.usercus_name
from Customerprice cp inner join CustomerLogin c
on cp.cust_id=c.cust_id
if exists(select cp.cust_id,p.PID from CustomerLogin c,Customerprice cp,Productable p where cp.cust_id!=@cust_id And cp.PID!=@PID)
select distinct p.Productprice,'manual' as Pricetype,c.cust_name,c.usercus_name
from Productable p,CustomerLogin c
where p.PID=@PID

am getting

Problems with GridView, ModalPopupExtender and UpdatePanel



I have a strange problem

On one page there is a GridView inside a ModalPopupExtender and this grid is filled through a button inside the UpdatePanel, this button displays the ModalPopup but empty grid (no grid appears) and it does not change the text of lblCantidad

This is the code


 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
<table class="tabla_1" width="900" align="center">
<td class="style13">
<asp:Label ID="Label1" runat="server" Text="Buscar:"></asp:Label>
<td class="style14">
<asp:TextBox ID="txtBusqueda" runat="server" Width="250px"></asp:TextBox>
 <asp:ImageButton ID="imgBuscar" ToolTip="Buscar" ImageAlign="AbsMiddle&q

Inplace Edit in GridView

In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.

GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

AJAX GridView Paging and Sorting using C# in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

GridView Paging Using Ajax in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend