Solved

asp.net / c# issue

Posted on 2011-09-22
5
205 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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Service Controller 1 23
imap mails 1 22
PrintingFoundIt(Almost!(Damn!)) 1 25
Get distinct values from excel or comm seperated file 4 23
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

815 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now