Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

asp.net / c# issue

Posted on 2011-09-22
5
Medium Priority
?
217 Views
Last Modified: 2012-05-12
I have a gridview, and data came from sql server.
On each row, I would like to add a link or button like <a href=aaa.aspx?PartNo=111>
When it is clicked, it will capture the PartNo (111) and generate a new web page
called 111.aspx and save into server root directory like c:\InetPub\www\project\111.aspx

is it possible? If yes, can you show me how to do it?

Thanks,
0
Comment
Question by:Webboy2008
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 36581056
Add a button field to the grid column list and give it a command argument.

Create an OnRowCommand for the Grid.

In the OnRowCommand, check the e.CommandArgument for "CreatePage" or whatever you put in in step 1.

Make sure your DataKeys for the Grid are setup to include the PartNo so you can pull it in the OnRowCommand

Pull the PartNo from the Grid.DataKeys (e contains the RowIndex)

Use a filestream object to create your [PartNo].aspx file on the server
   - this will require the webuser to have read/write access to the folder you want to put it in.

0
 

Author Comment

by:Webboy2008
ID: 36582028
Strickdd:

I need some working sample. In addition, I just have one more question. Once the webpage is saved.
can I also write some aspx script there?
Like after PartNo.aspx is done, I want to add some thing like
<a href=asssasdf.aspx>Click here</a> inside of the webpage...is it possible?
0
 
LVL 28

Accepted Solution

by:
strickdd earned 2000 total points
ID: 36582115
First off, I'm nost sure what you are trying to accomplish by this (frankly I don't care), but you can probably get away with one generic file that you display information based on querystring instead of creating a bunch of these .aspx files.

To answer your question:
Yes, if you follow the FileStream example link posted in the code section below, you will see how you can add any text to the file you wish.

<asp:GridView ID="PartsGrid" runat="server" AutoGenerateColumns="False" AllowSorting="True" DataSourceID="QueueDecisionData" OnRowCommand="PartsGrid_RowCommand" DataKeyNames="PartsNo">
	<Columns>
		<asp:ButtonField ButtonType="button" Text="Edit" CausesValidation="false" CommandName="EditRow" ItemStyle-HorizontalAlign="center" />
	</Columns>
</asp:GridView>

protected void PartsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
	{
		if (e.CommandName == "EditRow")
		{
			//Filestream example:http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx
		}
	}

Open in new window

0
 

Author Comment

by:Webboy2008
ID: 36587003
i would like to add aspx file.
and inside of aspx file, I would like to add some property like button and hidden field. is that possible?
0
 
LVL 28

Expert Comment

by:strickdd
ID: 36587542
yes, whatever you add to the filestream text will be added to the created .aspx file. You can add a button, you can add a hidden field, you can add the works of Shakespear if you want.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question