AXISHK
asked on
How to retrieve a deleted row in GridView
I have bounded a DataGrid to reflect a particular files in a folder. I'm using Visual Studio 2005 with VB coding.
1. Have any idea how to capture the filename when user click the "Delete" Button in GridView.
2. Is it possilbe to include more parameter in DataNavigateUrlFormatStrin g, say ="~/ListFolder.aspx?idir={ 0}",ifile= {2} />
Thanks.
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Dim upFolder As String = MapPath("~/DMS/")
Dim dir As New System.IO.DirectoryInfo(up Folder)
rptFiles.DataSource = dir.GetFiles()
rptFiles.DataBind()
DirTree.DataSource = dir.GetDirectories
DirTree.DataBind()
End Sub
<asp:gridview
id="dirTree"
autogeneratecolumns="false "
GridLines="None"
Runat="server" HorizontalAlign="Left">
<Columns>
<asp:HyperLinkField
DataTextField="Name"
DataNavigateUrlFields="Nam e"
DataNavigateUrlFormatStrin g="~/ListF older.aspx ?idir={0}" />
</Columns>
</asp:gridview>
1. Have any idea how to capture the filename when user click the "Delete" Button in GridView.
2. Is it possilbe to include more parameter in DataNavigateUrlFormatStrin
Thanks.
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Dim upFolder As String = MapPath("~/DMS/")
Dim dir As New System.IO.DirectoryInfo(up
rptFiles.DataSource = dir.GetFiles()
rptFiles.DataBind()
DirTree.DataSource = dir.GetDirectories
DirTree.DataBind()
End Sub
<asp:gridview
id="dirTree"
autogeneratecolumns="false
GridLines="None"
Runat="server" HorizontalAlign="Left">
<Columns>
<asp:HyperLinkField
DataTextField="Name"
DataNavigateUrlFields="Nam
DataNavigateUrlFormatStrin
</Columns>
</asp:gridview>
ASKER
Basically, not touching any Database, only retrieve the files from specifiy path and show on GridView and enable the "Delete" button per button. AFterwards, I willl delete the files from the server.
Thanks.
Thanks.
This is very over simplified as my code got the doc filename and path from the db based on the DocID for that particular row in the gridview.
You may have to do something like.....
<asp:Button CommandName=<%#eval("DocPa
then in your code behind
Imports System.IO
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
File.Delete(Server.MapPath
End Sub
the variable DocPath_name would be populated row by row based on the path to the folder and the filename
OnClick you would pass this value to the code behind which would then pass it to the File.Delete method
OnClick you would pass this value to the code behind which would then pass it to the File.Delete method
ASKER
I tried to pu the control under the "Columns" but doesn't work. It seems that GridView don't support the bind of this control. Any idea. Can you show me how you bind the selected column on GridView ?
Thanks
<Columns>
<asp:HyperLinkField
DataTextField="Name"
DataNavigateUrlFields="Nam
DataNavigateUrlFormatStrin
</Columns>
ASKER
Protected Sub dirTree_RowDeleting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls. GridViewDe leteEventA rgs) Handles rptFiles.RowDeleting
End Sub
Bascially the event RowDeleting is called for my previous posted code but I don't know how to retrieve the file name binded to the row of the GridView. Any idea ?
Again, if you think there is a way to get around of this, I could modify my coding on GridView.
tks
System.Web.UI.WebControls.
End Sub
Bascially the event RowDeleting is called for my previous posted code but I don't know how to retrieve the file name binded to the row of the GridView. Any idea ?
Again, if you think there is a way to get around of this, I could modify my coding on GridView.
tks
Which bit is the problem?
DataNavigateUrlFormatStrin g="~/ListF older.aspx ?idir={0}"
this bit?
DataNavigateUrlFormatStrin
this bit?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks. Sound like this is a way to go.
On more things, how to change the "DataNavigateUrlFormatStri ng" per row before bind to GridView using the RowDataBound event. I could access the content of the DataNavigaterUrlField but I want to change the NavigterUrlFormatString dynamically.
Thanks again.
On more things, how to change the "DataNavigateUrlFormatStri
Thanks again.
Forced accept.
Computer101
Community Support Moderator
Computer101
Community Support Moderator
I ask as I have just done exactly that and could post my code