Link to home
Start Free TrialLog in
Avatar of Webboy2008
Webboy2008

asked on

asp.net / c# issue

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,
Avatar of strickdd
strickdd
Flag of United States of America image

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.

Avatar of Webboy2008
Webboy2008

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of strickdd
strickdd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
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.