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..?
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