G
Guest
Problem in getting value from textbox & radiobuttonlist to a valuable inside
a datagid.
I want to insert a record into a table thru datagrid. Here is the code (see
below)
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.ItemCommand
Select Case e.CommandName
Case "rate_it"
If ((e.Item.ItemType <> ListItemType.Header) And (e.Item.ItemType <>
ListItemType.Footer)) Then
DocumentID = Convert.ToInt32(e.Item.Cells(7).Text)
Dim UserIP As String
UserIP = CStr(Request.UserHostAddress)
Dim comments As String
Dim TB As TextBox
TB = CType(e.Item.FindControl("TestBox1"), TextBox)
comments = TB.Text >>>>>>>>>>>>>>>>>>>>>>>>>>> Object reference not set to
an instance of an object. !!!!!!!!!!!!!!!!!!!!!!!!!!here is where I get
error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Description: An unhandled exception occurred during the execution of the
current web request. Please review
Dim rate As String
Dim RBL As New RadioButtonList
RBL = CType(e.Item.FindControl("RadioButtonList1"), RadioButtonList)
rate = Request.Form("RadioButtonList1")
Dim conPubs As SqlConnection
Dim cmdIns As SqlCommand
conPubs = New SqlConnection("server=BGLAMDJVELU;Database=Pubs;Integrated
security=sspi")
cmdIns = New SqlCommand("INSERT INTO tbl_rating (rating, ip, documentID,
usercomment) VALUES (" & rate & " ,'" & UserIP & "'," & DocumentID & ",'" &
comments & "');", conPubs)
conPubs.Open()
cmdIns.ExecuteReader()
conPubs.Close()
End If
End Select
Pls help me I have been working for more than 5 days
Thx
Jk
a datagid.
I want to insert a record into a table thru datagrid. Here is the code (see
below)
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.ItemCommand
Select Case e.CommandName
Case "rate_it"
If ((e.Item.ItemType <> ListItemType.Header) And (e.Item.ItemType <>
ListItemType.Footer)) Then
DocumentID = Convert.ToInt32(e.Item.Cells(7).Text)
Dim UserIP As String
UserIP = CStr(Request.UserHostAddress)
Dim comments As String
Dim TB As TextBox
TB = CType(e.Item.FindControl("TestBox1"), TextBox)
comments = TB.Text >>>>>>>>>>>>>>>>>>>>>>>>>>> Object reference not set to
an instance of an object. !!!!!!!!!!!!!!!!!!!!!!!!!!here is where I get
error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Description: An unhandled exception occurred during the execution of the
current web request. Please review
Dim rate As String
Dim RBL As New RadioButtonList
RBL = CType(e.Item.FindControl("RadioButtonList1"), RadioButtonList)
rate = Request.Form("RadioButtonList1")
Dim conPubs As SqlConnection
Dim cmdIns As SqlCommand
conPubs = New SqlConnection("server=BGLAMDJVELU;Database=Pubs;Integrated
security=sspi")
cmdIns = New SqlCommand("INSERT INTO tbl_rating (rating, ip, documentID,
usercomment) VALUES (" & rate & " ,'" & UserIP & "'," & DocumentID & ",'" &
comments & "');", conPubs)
conPubs.Open()
cmdIns.ExecuteReader()
conPubs.Close()
End If
End Select
Pls help me I have been working for more than 5 days
Thx
Jk