Click here to Skip to main content
15,613,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ..

i m getting Error in Gridview when i m trying to gridview_rowupdatin()event

error : NullReferenceException was Unhandled by user code

object reference not set to an instance of an object

What i m doing wreong here..?


VB
Protected Sub GrdHRProcess_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GrdHRProcess.RowCommand

       Dim MyConnection1 As SqlConnection
       Dim uid As String
       MyConnection1 = New SqlConnection(ConfigurationManager.ConnectionStrings("HRProcessConnectionString").ConnectionString)
       Dim sql1 As String
       sql1 = "select max(UDetailId) from HRProcess_Detail"
       Dim com As SqlCommand = New SqlCommand(sql1, MyConnection1)
       com.Connection.Open()
       uid = Convert.ToString(com.ExecuteScalar)
       com.Connection.Close()

       uid = uid + 1

       Dim conn As New SqlConnection
       conn = New SqlConnection(ConfigurationManager.ConnectionStrings("HRProcessConnectionString").ConnectionString)

       If (e.CommandName.Equals("AddNew")) Then



           Dim txtNewName1 As TextBox = GrdHRProcess.FooterRow.FindControl("txtNewName")
           Dim txtNewContact1 As TextBox = GrdHRProcess.FooterRow.FindControl("txtNewContact")
           Dim txtNewCallDate1 As TextBox = GrdHRProcess.FooterRow.FindControl("txtNewCallDate")
           Dim txtNewCallTime1 As TextBox = GrdHRProcess.FooterRow.FindControl("txtNewCallTime")
           Dim txtNewStartDate1 As TextBox = GrdHRProcess.FooterRow.FindControl("txtNewSD")
           Dim txtNewClass1 As TextBox = GrdHRProcess.FooterRow.FindControl("txtNewClass")
           Dim ddlNewStatus1 As DropDownList = GrdHRProcess.FooterRow.FindControl("ddlNewStatus")
           conn.Open()
           Dim cmd As New SqlCommand("Insert into HRProcess_Detail(UDetailId,CandidateName,ContactNo,CallDate,CallTime,StartDate,Class,Status) values('" & uid & "','" & txtNewName1.Text & "','" & txtNewContact1.Text & "','" & txtNewCallDate1.Text & "', '" & txtNewCallTime1.Text & "','" & txtNewStartDate1.Text & "', '" & txtNewClass1.Text & "','" & ddlNewStatus1.Text & "')", conn)
           cmd.ExecuteNonQuery()

           conn.Close()

       End If
   End Sub
Posted
Updated 12-Jul-11 3:07am
v2
Comments
Uday P.Singh 12-Jul-11 9:02am    
can you post your code?

1 solution

the exception is self explanatory, NullReferenceException refers that you are trying to access member fields or function types on an object reference that points to null.

hope it helps :)

for further queries comment here!!
 
Share this answer
 
Comments
nikunjnik 12-Jul-11 9:08am    
i have sent u a code .. check it out
nikunjnik 12-Jul-11 9:21am    
sachin sharma...

did u get any Idea..?

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