0

I’ve been trying to wrap my brain around this now for days,
and I’m getting nowhere, so please bear with me…

To Remove file on click of linkbutton I have below code:

aspx page:

<asp:LinkButton ID="RemovefileId" runat="server" CommandName="RemoveFile"  OnCommand="RemoveFilefunction" CommandArgument=<%#Eval("filepath")%>>LinkButton</asp:LinkButton>

aspx.cs page

protected void RemoveFilefunction(object sender, CommandEventArgs e)
 {
            string x = e.CommandArgument.ToString();//why Here x is empty string 
  //If U have any idea to delete file then help me..
  }

plz tell me any wrong in aspx file.

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by amitshrivas
0

System.IO.File.Delete method.

for example,

file="~/samples/file.txt";
System.IO.File.Delete(MapPath(file));
0

I’ve been trying to wrap my brain around this now for days,
and I’m getting nowhere, so please bear with me…

To Remove file on click of linkbutton I have below code:

aspx page:

<asp:LinkButton ID="RemovefileId" runat="server" CommandName="RemoveFile"  OnCommand="RemoveFilefunction" CommandArgument=<%#Eval("filepath")%>>LinkButton</asp:LinkButton>

aspx.cs page

protected void RemoveFilefunction(object sender, CommandEventArgs e)
 {
            string x = e.CommandArgument.ToString();//why Here x is empty string 
  //If U have any idea to delete file then help me..
  }

plz tell me any wrong in aspx file.

............
i think in aspx page u made a mistake..
i have tried this code and i m getting the CommandArguement value..
Modification...u need to do..

CommandArgument='<%#Eval("filepath")%>'

i hope this modification will solve the problem

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.