I want to Edit Grid View Rows along with file download option. I can execute Edit and File download separately. But when I execute both, and press Edit button, it gives me error:Could not find a part of the path 'c:\upload\'. This path is right and file download can be executed from this path.
namespace gerp_support
{
public partial class Admin : System.Web.UI.Page
{
string cs = ConfigurationManager.ConnectionStrings["GerpConnStr"].ConnectionString;
SqlConnection con;
SqlDataAdapter adapt;
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.ShowData();
}
}
private void ShowData()
{
dt = new DataTable();
con = new SqlConnection(cs);
con.Open();
adapt = new SqlDataAdapter("SELECT ID,request_no,requestor,request_type, request_area, subject,description,attachment,req_status,admin_comment FROM request where req_status='Open' order by ID", con);
adapt.Fill(dt);
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
con.Close();
}
protected void GridView1_RowEditing(object sender, System.Web.UI.WebControls.GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
ShowData();
}
protected void gvFiles_RowCommand(object sender, GridViewCommandEventArgs e)
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + e.CommandArgument);
string p = @"c:\upload\";
Response.TransmitFile(p + e.CommandArgument);
Response.End();
}
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e)
{
Label id = GridView1.Rows[e.RowIndex].FindControl("lbl_id") as Label;
Label request_no = GridView1.Rows[e.RowIndex].FindControl("lbl_request_no") as Label;
Label requestor = GridView1.Rows[e.RowIndex].FindControl("lbl_requestor") as Label;
Label request_type = GridView1.Rows[e.RowIndex].FindControl("lbl_request_type") as Label;
Label request_area = GridView1.Rows[e.RowIndex].FindControl("lbl_request_area") as Label;
Label subject = GridView1.Rows[e.RowIndex].FindControl("lbl_subject") as Label;
Label description = GridView1.Rows[e.RowIndex].FindControl("lbl_description") as Label;
TextBox req_status = GridView1.Rows[e.RowIndex].FindControl("txt_req_status") as TextBox;
TextBox admin_comment = GridView1.Rows[e.RowIndex].FindControl("txt_admin_comment") as TextBox;
con = new SqlConnection(cs);
con.Open();
SqlCommand cmd = new SqlCommand("Update request set req_status='" +req_status.Text+ "',admin_comment='" +admin_comment.Text+ "' where ID=" + Convert.ToInt32(id.Text), con);
cmd.ExecuteNonQuery();
con.Close();
GridView1.EditIndex = -1;
ShowData();
}
What I have tried:
I have tried Edit Grid View Row and File Download separately and it worked. But when I execute both and press Edit button, it gives error:Could not find a part of the path 'c:\upload\'