명령 텍스트를 초기화하는 동안 오류가 발생했습니다. SQL 명령 개체에서 SQL 업데이트 쿼리를 추가 할 수 없습니다.
TextBox id = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtid");
TextBox Loginid = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtgvusername");
TextBox EmployeeId = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtEmployeeId");
TextBox Fullname = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtFullname");
TextBox Password = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtPassword");
TextBox ContactNo = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtContactNo");
TextBox MailId = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtMailid");
TextBox Location = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtLocation");
TextBox Roles = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtRoles");
CheckBox chkLeads = (CheckBox)gvUserDetails.Rows[e.RowIndex].FindControl("chkLeads");
CheckBox ChkSales = (CheckBox)gvUserDetails.Rows[e.RowIndex].FindControl("ChkSales");
CheckBox ChkReports = (CheckBox)gvUserDetails.Rows[e.RowIndex].FindControl("ChkReports");
CheckBox ChkPayments = (CheckBox)gvUserDetails.Rows[e.RowIndex].FindControl("ChkPayments");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Update tbl_AdminLogin set FullName='" + txtfullName.Text + "',Password='" + txtPassword.Text + "',ContactNo='" + txtContact.Text + "',Mailid='" + txtMailid.Text + "',Location='" + txtLocation.Text + "',Roles='" + Roles.Text + "',Leads='" + chkLeads.Text + "',Sales='" + ChkSales.Checked + "',Reports='" + ChkSales.Text + "',Payments='" + ChkPayments.Text + "',EmployeeId='" + id.Text + "' where id='" + id.Text + "'";//getting error here
Control
찾으려 는 s 중 하나 를 찾을 수없고 FindControl
반환 할 수 없으며 해당 컨트롤 null
의 Text
(또는 Checked
) 속성을 사용하고있었습니다 null
. 컨트롤의 이름이 무엇인지 모르겠지만 문제가 그 줄에 있다고 생각합니다.
CheckBox chkLeads = (CheckBox)gvUserDetails.Rows[e.RowIndex].FindControl("chkLeads");
나머지 이름에는 CheckBox
"chk"대신 "Chk"라는 접두사가 있으므로 문제를 해결하고 질문에 대한 처음 두 개의 주석을 살펴보십시오.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다