Solved

asp.net / c# issue

Posted on 2011-09-22
5
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
C# MVC Insert Multiple Row into DB 2 61
Query in AngularJS 8 44
Asp.Net Session Question 2 33
Include MS Database in Winforms Project using Intellilock 5 21
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 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