Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello frnds,

Am working on asp.net c#, SqlServer 2005.

presently am working on gridview footer textboxes, these are working fine and storing in database.

now my requirement is: I also have 2 textboxes outside the gridveiw.
I want to insert including these textbox values into the database when gridview add button clicks from footer.

Note: these 2 textboxes are outside the gridview.
1)TxtStudentRemarks
2)TxtTeacherRemarks

Please help me how to do these ?

This is my code for footer textboxes. its running fine, but also i want to insert outside textboxes values also, when footer add button click.

C#
if (e.CommandName.Equals("AddNew"))
        {

            TextBox TxtFirstName = (TextBox)GvRecords.FooterRow.FindControl("txtFTRFirstName");
            TextBox TxtLastName = (TextBox)GvRecords.FooterRow.FindControl("txtFTRLastName");
            TextBox TxtStudentName = (TextBox)GvRecords.FooterRow.FindControl("txtFTRStudentName");
            TextBox TxRollNo = (TextBox)GvRecords.FooterRow.FindControl("txtFTRRollNo ");
            TextBox TxtResult = (TextBox)GvRecords.FooterRow.FindControl("txtFTRResult");
    
            con.Open();
            
            SqlCommand cmd = new SqlCommand("INSERT into StudentRecords(FirstName,LastName,StudentName,RollNo,Result)VALUES('" + TxtFirstName.Text + "','" + TxtLastName.Text + "','" + TxtStudentName.Text + "','" + TxtRollNo.Text + "', '" + TxtResult.Text + "')", con);
            
            int result = cmd.ExecuteNonQuery();
            con.Close();
            if (result == 1)
            {
                LoadRecords();
                ScriptManager.RegisterStartupScript(this, this.GetType(), "RunCode", "javascript:alert('Added successfully');", true);
            }
           
        }


please help thanks.
Posted
Updated 2-Jul-13 1:56am
v2
Comments
jaideepsinh 2-Jul-13 8:07am    
You can add your value same as other.
You want to add that textbox value in same(StudentRecords) table or in other table.

u can directly refer those 2 controls out side gridview in item command direclty
 
Share this answer
 
You want to add that textbox value in same(StudentRecords) table then try this:

SqlCommand cmd = new SqlCommand("INSERT into StudentRecords(FirstName,LastName,StudentName,RollNo,Result,StuRemark,TacherRemark)VALUES('" + TxtFirstName.Text + "','" + TxtLastName.Text + "','" + TxtStudentName.Text + "','" + TxtRollNo.Text + "', '" + TxtResult.Text + "','" + TxtStudentRemark.Text + "')",'" + TxtTeacherRemark.Text + "', con);
 
Share this answer
 
Comments
Member239258 3-Jul-13 6:41am    
Thank you jaideepsinh, its works for me.....
jaideepsinh 3-Jul-13 6:57am    
Thank's for accept as answer vote pls.

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