Dot-Net
Welcome to DOT-Net Forum:)

Join the forum, it's quick and easy

Dot-Net
Welcome to DOT-Net Forum:)
Dot-Net
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Dot-Net

A place for .Net professionals to exchange their knowledge and develop their skills.

Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» 15 Years Boys Sex
Editing the file EmptySun Jun 08, 2014 1:06 pm by jaiminekea

» Ft8u245 Dll Free Download Mega
Editing the file EmptySun Jun 08, 2014 4:49 am by jaiminekea

» Ft8u245 Dll Free Download Mega
Editing the file EmptySun Jun 08, 2014 4:47 am by jaiminekea

» Xxx Child 14 Years Old Girls Fuck Her Self Rar
Editing the file EmptyFri Jun 06, 2014 7:25 pm by jaiminekea

» Keyscrambler-personal-2.8.1
Editing the file EmptyFri May 30, 2014 4:17 pm by jaiminekea

» Lenovo-drivers-update-utility-2.6
Editing the file EmptyFri May 30, 2014 2:50 pm by jaiminekea

» MOBILedit 2 5 0 7
Editing the file EmptyThu May 29, 2014 7:54 pm by jaiminekea

» Scwcd-5-certification-training-lab-1.0
Editing the file EmptyWed May 28, 2014 12:25 am by jaiminekea

» Media Player Classic HomeCinema 1.5.3.3514
Editing the file EmptyTue May 27, 2014 10:43 pm by jaiminekea

May 2024
MonTueWedThuFriSatSun
  12345
6789101112
13141516171819
20212223242526
2728293031  

Calendar Calendar

Who is online?
In total there is 1 user online :: 0 Registered, 0 Hidden and 1 Guest

None

[ View the whole list ]


Most users ever online was 88 on Sun Jun 27, 2021 7:35 am

You are not connected. Please login or register

Editing the file

2 posters

Go down  Message [Page 1 of 1]

1Editing the file Empty Editing the file Fri Jun 12, 2009 8:32 pm

Dorababu



Hello one an all,
I am having a requirement regarding my work i am doing. The requirement goes as follows. I am having my data saved in the SQL table as follows.

Id Name filename
----------------------
1 ABC abc.doc
------------------------
2 XYZ xyz.pdf
-------------------------
Like this some other file formats...

What i am doing is i am going to display all these in a grid view as follows.

Id Name Filename
--------------------------------
1 ABC abc.doc Edit
---------------------------------
2 XYZ xyz.pdf Edit
---------------------------------

What i need is when i click on edit i would like to get a file upload control there i will select a new file like some pqr.txt and i would like to replace the old file. For example if i click Edit in the first column then a file upload should appear and there what ever file i uploaded should be saved in place of abc.doc after clciking update and also if i would like to edit the name also i shoul. So can any one give me the code for my requirement...

Thanks In Advance,
M.DOrababu

2Editing the file Empty Guess this will be useful;) Fri Jun 12, 2009 10:35 pm

Admin


Admin

I think you can add FileUpload control in the Edit template of the gridview and it can be used to save the uploading file.The following is sample code for your reference.Wish this help you.

HTML Code in .ASPX file:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="AccessDataSource1" Width="148px" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblFileUpLoad" runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="true" ShowDeleteButton="true" />
</Columns>
</asp:GridView>

<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/AccessDb.mdb"
SelectCommand="SELECT [ID], [Name] FROM [task]" DeleteCommand="DELETE FROM [task] WHERE [ID] = ?" InsertCommand="INSERT INTO [task] ([ID], [Name]) VALUES (?, ?)" UpdateCommand="UPDATE [task] SET [Name] = ? WHERE [ID] = ?">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
</InsertParameters>
</asp:AccessDataSource>

Code Behind File:

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(GridView1.EditIndex == -1) return;
FileUpload fileUpLoad = GridView1.Rows[GridView1.EditIndex].FindControl("FileUpload1") as FileUpload;
string fileName = fileUpLoad.FileName;
string fullPath = Path.GetFullPath(fileName);
fileUpLoad.SaveAs(fullPath);
}

https://dotnet.forumotion.com

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum