473,396 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GridView in ModalDialog +C# +ASP.NET

fayazmd
41
Hi,

I am creating a webpage having GridView. In GridView i have a column Accolades, a link button column. On clicking of Accolades, a modal window is opened. That modal window has a gridview, where i am displaying all uploaded files. This GridView first column is a template column, having link button, text of the button will be FileName. On clicking of file name file should be opened. For that I wrote a method to open the file. Its working fine if you are opening as a popup(window.open). But my requirement is to show in modal(window.showmodaldialog).

If you are clicking the file name in modal window, the file is not opening. Its calling the method to open the file, but file is not opening. I put <base target="_self"> in aspx file of modal page.

Any suggestions?

Here is the code to open the file

protected void DownloadFile(string szFilePath)
{
Stream iStream;
byte[] buffer = new byte[99999999];
int length;
long dataToRead;
string filename = Path.GetFileName(szFilePath);
try
{
iStream = new FileStream(szFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
dataToRead = iStream.Length;

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);

while (dataToRead > 0)
{
if (Response.IsClientConnected)
{
length = iStream.Read(buffer, 0, 99999998);
Response.OutputStream.Write(buffer, 0, length);

Response.Flush();

buffer = new byte[99999999];
dataToRead = dataToRead - length;
}
else
{
dataToRead = -1;
}
}
iStream.Dispose();
}
catch (Exception oExp)
{
throw oExp;
}
}
Jun 11 '08 #1
1 3192
fayazmd
41
Hi,

I am creating a webpage having GridView. In GridView i have a column Accolades, a link button column. On clicking of Accolades, a modal window is opened. That modal window has a gridview, where i am displaying all uploaded files. This GridView first column is a template column, having link button, text of the button will be FileName. On clicking of file name file should be opened. For that I wrote a method to open the file. Its working fine if you are opening as a popup(window.open). But my requirement is to show in modal(window.showmodaldialog).

If you are clicking the file name in modal window, the file is not opening. Its calling the method to open the file, but file is not opening. I put <base target="_self"> in aspx file of modal page.

Any suggestions?

Here is the code to open the file

protected void DownloadFile(string szFilePath)
{
Stream iStream;
byte[] buffer = new byte[99999999];
int length;
long dataToRead;
string filename = Path.GetFileName(szFilePath);
try
{
iStream = new FileStream(szFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
dataToRead = iStream.Length;

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);

while (dataToRead > 0)
{
if (Response.IsClientConnected)
{
length = iStream.Read(buffer, 0, 99999998);
Response.OutputStream.Write(buffer, 0, length);

Response.Flush();

buffer = new byte[99999999];
dataToRead = dataToRead - length;
}
else
{
dataToRead = -1;
}
}
iStream.Dispose();
}
catch (Exception oExp)
{
throw oExp;
}
}
Jun 14 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
6
by: praan | last post by:
I am trying to display xml content in a modaldialog window using window.showModalDialog(), but a blank modaldialog window is displayed. can anyone help me with this. Any other way present to...
3
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a...
4
by: =?Utf-8?B?Y2hyaXM=?= | last post by:
I have a perent gridview which includes in a template field a child gridview. Child gridview includes command buttons for opening different windows based on its row selected. I used the code...
0
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box...
6
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the...
5
by: Eric | last post by:
Hi, there are several gridviews all with a linkbutton which all trigger the same procedure. I need to know from which gridview the linkbutton has been clicked. Thanks Eric Here the code:
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.