2017-12-28 14 views
-5

Was kann ich ... ich von vielen Codes versucht, Google-Suche aber nicht ... plz help me„Objektverweis nicht auf eine Instanz eines Objekts festgelegt“ in meinem gridview

protected void RegistrationDetails_RowUpdating(object sender, GridViewUpdateEventArgs e) 
    { 
     int stdid = Convert.ToInt32(RegistrationDetails.DataKeys[e.RowIndex].Value.ToString()); 
     int stdroll = Convert.ToInt32(RegistrationDetails.DataKeys[e.RowIndex].Value.ToString()); 
     int clsid = Convert.ToInt32(RegistrationDetails.DataKeys[e.RowIndex].Value.ToString()); 
     //DateTime tdob = Convert.ToDateTime(RegistrationDetails.DataKeys[e.RowIndex].Value); 
     int vyear = Convert.ToInt32(RegistrationDetails.DataKeys[e.RowIndex].Value.ToString()); 
     //DateTime vadmdate = Convert.ToDateTime(RegistrationDetails.DataKeys[e.RowIndex].Value); 
     GridViewRow row = (GridViewRow)RegistrationDetails.Rows[e.RowIndex]; 
     Label lblID = (Label)RegistrationDetails.Rows[e.RowIndex].FindControl("lblID"); 
     //TextBox txtname=(TextBox)gr.cell[].control[]; 
     //TextBox tid = RegistrationDetails.Rows[e.RowIndex].Cells[0].Controls[0] as TextBox; 
     //TextBox troll = RegistrationDetails.Rows[e.RowIndex].Cells[1].Controls[0] as TextBox; 
     TextBox tname = RegistrationDetails.Rows[e.RowIndex].Cells[3].Controls[0] as TextBox; 
     TextBox tdob = RegistrationDetails.Rows[e.RowIndex].Cells[4].Controls[0] as TextBox; 
     TextBox taddress = RegistrationDetails.Rows[e.RowIndex].Cells[5].Controls[0] as TextBox; 
     TextBox tcontactp = RegistrationDetails.Rows[e.RowIndex].Cells[6].Controls[0] as TextBox; 
     TextBox tgender = RegistrationDetails.Rows[e.RowIndex].Cells[7].Controls[0] as TextBox; 
     TextBox tmobile = RegistrationDetails.Rows[e.RowIndex].Cells[8].Controls[0] as TextBox; 
     //TextBox tyear = RegistrationDetails.Rows[e.RowIndex].Cells[8].Controls[0] as TextBox; 
     TextBox tjdate = RegistrationDetails.Rows[e.RowIndex].Cells[10].Controls[0] as TextBox; 
     TextBox tpass = RegistrationDetails.Rows[e.RowIndex].Cells[11].Controls[0] as TextBox; 
     //TextBox tclsid = RegistrationDetails.Rows[e.RowIndex].Cells[11].Controls[0] as TextBox; 
     TextBox tsecid = RegistrationDetails.Rows[e.RowIndex].Cells[12].Controls[0] as TextBox; 

     //string vfullname = fullname.Text; 
     //string vaddress = address.Text; 
     //string vcperson = cperson.Text; 
     //string vmobile = mobile.Text; 
     //string vpass = pass.Text; 
     //TextBox textadd = (TextBox)row.FindControl("txtadd"); 
     //TextBox textc = (TextBox)row.FindControl("txtc"); 
     RegistrationDetails.EditIndex = -1; 
     con.Open(); 
     //SqlCommand cmd = new SqlCommand("SELECT * FROM detail", conn); 
     OleDbCommand cmd = new OleDbCommand("update registration set Roll=" + stdroll + ", Full_Name='" + tname.Text + "', Date_of_Birth='" + tdob.Text + "',Address='" + taddress.Text.Trim() + "', Contact_Person='" + tcontactp.Text + "', Gender='" + tgender.Text + "', Mobile='" + tmobile.Text + "', CYear=" + vyear + ", Joining_Date='" + tjdate.Text + "', UPassword='" + tpass.Text + "', Class_ID=" + clsid + ", Section_ID='" + tsecid.Text + "' where Student_ID=" + stdid + "", con); 
     cmd.ExecuteNonQuery(); 
     con.Close(); 
     refreshdata(); 
    } 
+0

können Sie die vollständige Fehlermeldung –

+0

teilen Bitte nehmen Sie die Tour https://StackOverflow.com/Tour, damit Sie uns helfen können, Ihnen zu helfen :-) – Zorkind

Antwort

0

Sie sind nicht Null-Überprüfungen einer Ihrer Variablenzuweisungen für einen Start.

Meine Vermutung ist, dass eine Ihrer Zellen, die Sie zu werfen versuchen, leer ist.

Verwandte Themen