Click here to Skip to main content
15,901,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to Upload a PDF file From Gridview, when it is in Editmode.
===============================================================

Dear Frnds,

Am working on ASP.NET Gridview. am editing a record using Modal Popup extender...its working fine.

but i want to add File upload control also, so i can upload(REPLACE) another PDF file when it is in edit mode.

This is my Design & code.

FileUpload control in design mode.
-----------------------------------

C#
<asp:FileUpload ID="FileUpload_Edit" runat="server" />



=====================================

and this is my Code.

C#
protected void btnUpdate_Click(object sender, EventArgs e)
   {
       con.Open();
SqlCommand cmd = new SqlCommand("UPDATE AddUsers SET FirstName='" + txtfname.Text + "',LastName='" + txtlname.Text + "',EmpNo='" + txtEmpNo.Text + "',Sponsor='" + txtSponsor.Text + "',ManagerName='" + txtManagerName.Text + "', Dept='" + txtDepartment.Text + "',Location='" + txtLocation.Text + "',OffTelNo='" + txtOffTelNo.Text + "',MobileNo='" + txtMobileNo.Text + "',IssuedDate='" + txtIssueDate.Text + "',ExpiryDate='" + txtExpiryDate.Text + "' Where Id=@Id", con);
 
 Collapse | Copy Code
cmd.Parameters.AddWithValue("@FirstName", txtfname.Text);
        cmd.Parameters.AddWithValue("@LastName", txtlname.Text);
        cmd.Parameters.AddWithValue("@EmpNo", txtEmpNo.Text);
        cmd.Parameters.AddWithValue("@Sponsor", txtSponsor.Text);
        cmd.Parameters.AddWithValue("@ManagerName", txtManagerName.Text);
 
        cmd.Parameters.AddWithValue("@Dept", txtDepartment.Text);
 
        cmd.Parameters.AddWithValue("@Location", txtLocation.Text);
 
        cmd.Parameters.AddWithValue("@OffTelNo", txtOffTelNo.Text);
 
        cmd.Parameters.AddWithValue("@MobileNo", txtMobileNo.Text);
 
        cmd.Parameters.AddWithValue("@IssuedDate", txtIssueDate.Text);
 
        cmd.Parameters.AddWithValue("@ExpiryDate", txtExpiryDate.Text);
        cmd.Parameters.AddWithValue("@Id", Convert.ToInt32(lblID.Text));
 
 cmd.ExecuteNonQuery();
        con.Close();
 
 ScriptManager.RegisterStartupScript(this, this.GetType(), "RunCode", "javascript:alert('Updated successfully');", true);
        BindGV();
}

Please help me.

THANKS.
Posted
Updated 1-Jul-13 0:12am
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900