Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have taken RowEditing feature to a new window in my program. Please have a look at my code first:
C#
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
     lblSet.Text = GridView1.Rows[e.NewEditIndex].Cells[2].Text;
     MultiView1.SetActiveView(vRecord);

     btnSave.Visible = false;
     btnBacktoHome.Visible = true;
     //this.lblMedium.Text = GridView1.Rows[e.NewEditIndex].Cells[1].Text;


     using (SqlConnection con = new SqlConnection("Data Source=MEHDI-PC\\SQLEXPRESS;Initial Catalog=PIMS;Integrated Security=True"))
     {
         using (SqlCommand cmd = new SqlCommand())
         {
             String sql = "select [DocumentID],[Ref],[Subject],[Src],[Dst],[Medium],[Date_Printed],[Date_Received],[Document_Type],[Action_Required],[Due_Date],[Actual_Date],[Content],[Tag],[Issue_No],[Attachment],[Notes],[Assigned_To],[Reply_Ref],[Priority],[Status],[Response],[Physical_File_No],[Physical_Rack_Location] from dbo.Documents1 where [DocumentId]=N'" + GridView1.Rows[e.NewEditIndex].Cells[2].Text + "'";
             cmd.Connection = con;
             cmd.CommandText = sql;
             con.Open();

             //SqlDataAdapter da = new SqlDataAdapter(sql,con);
             //DataTable dt = new DataTable();
             DataSet ds = new DataSet();
             using (SqlDataAdapter adp = new SqlDataAdapter(cmd))
             {
                 adp.Fill(ds);
             }


             this.txtRef.Text = ds.Tables[0].Rows[0][1].ToString();
             this.txtSubject.Text = ds.Tables[0].Rows[0][2].ToString();
             this.ddlSource.Text = ds.Tables[0].Rows[0][3].ToString();
             this.ddlDestination.Text = ds.Tables[0].Rows[0][4].ToString();
             this.ddlMedium.Text = ds.Tables[0].Rows[0][5].ToString();
             this.txtDatePrinted.Text = ds.Tables[0].Rows[0][6].ToString();
             this.txtDateReceived.Text = ds.Tables[0].Rows[0][7].ToString();
             this.ddlDocumentType.Text = ds.Tables[0].Rows[0][8].ToString();
             this.cbxAction.Checked = ds.Tables[0].Rows[0][9].Equals(cbxAction.Checked);
             this.txtDueDate.Text = ds.Tables[0].Rows[0][10].ToString();
             this.txtActualDate.Text = ds.Tables[0].Rows[0][11].ToString();
             this.txtContent.Text = ds.Tables[0].Rows[0][12].ToString();
             this.txtTag.Text = ds.Tables[0].Rows[0][13].ToString();
             this.txtIssue.Text = ds.Tables[0].Rows[0][14].ToString();

             //this.fileupload1 = ds.Tables[0].Rows[0][15] ;

             this.txtNotes.Text = ds.Tables[0].Rows[0][16].ToString();
             this.ddlAssignedTo.Text = ds.Tables[0].Rows[0][17].ToString();
             this.txtReplyRef.Text = ds.Tables[0].Rows[0][18].ToString();
             this.ddlPriority.Text = ds.Tables[0].Rows[0][19].ToString();
             this.ddlStatus.Text = ds.Tables[0].Rows[0][20].ToString();
             this.ddlResponse.Text = ds.Tables[0].Rows[0][21].ToString();
             this.txtPhysicalFileNo.Text = ds.Tables[0].Rows[0][22].ToString();
             this.txtPhysicalRackLocation.Text = ds.Tables[0].Rows[0][23].ToString();

             if (con != null)
             {
                 con.Close();
             }
             btnUpdate.Visible = true;
             btnSearch.Visible = false;
             BindGrid();
         }
     }
}


When the RowEditing event fires, a new page is opened in my program in which all the fields of the record are rendered. Users edit any field they want, and when they press update button given at the bottom of this page, Rowupdating event fires.

Now as the code shows, I am referring to a textbox like :

C#
this.txtRef.Text = ds.Tables[0].Rows[0][1].ToString();


I am actually stuck with fileupload control. I am not sure how to refer it on my new window. That is,

C#
//this.fileupload1 = ds.Tables[0].Rows[0][15] ;


I have commented out this line of code for the other code to run smoothly. I have read online how to work with fileupload in a gridview but all the information I came across was about RowEditing design that is implemented within the GridView, not in a new window. Any help will be much appreciated. Kind regards.
Posted
Comments
JoCodes 18-Sep-13 4:06am    
Whats the problem you facing exactly? Trying to set the filename for the uploadcontrol or something?
[no name] 18-Sep-13 5:56am    
no , I am trying to connect Fileupload control to the dataset. For example in the following line of code

this.txtRef.Text = ds.Tables[0].Rows[0][1].ToString();

I am referring to txtRef (TextBox) and assigning ds.table[0].rows[0][1] value to it.

I want first is, when I assign a filepath in fileupload control , how can it assign to dataset's table ? Is it possible?

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