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_ItemC ommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs ) Handles
DataGrid1.ItemC ommand
Select Case e.CommandName
Case "rate_it"
If ((e.Item.ItemTy pe <> ListItemType.He ader) And (e.Item.ItemTyp e <>
ListItemType.Fo oter)) Then
DocumentID = Convert.ToInt32 (e.Item.Cells(7 ).Text)
Dim UserIP As String
UserIP = CStr(Request.Us erHostAddress)
Dim comments As String
Dim TB As TextBox
TB = CType(e.Item.Fi ndControl("Test Box1"), 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.Fi ndControl("Radi oButtonList1"), RadioButtonList )
rate = Request.Form("R adioButtonList1 ")
Dim conPubs As SqlConnection
Dim cmdIns As SqlCommand
conPubs = New SqlConnection(" server=BGLAMDJV ELU;Database=Pu bs;Integrated
security=sspi")
cmdIns = New SqlCommand("INS ERT INTO tbl_rating (rating, ip, documentID,
usercomment) VALUES (" & rate & " ,'" & UserIP & "'," & DocumentID & ",'" &
comments & "');", conPubs)
conPubs.Open()
cmdIns.ExecuteR eader()
conPubs.Close()
End If
End Select
Pls help me I have been working for more than 5 days
Thx
Jk 5 2297
The error seems straighforward. There is no TextBox1 for that item...
Check out what e.Item.ItemType is when you get that error...I bet it isn't
what you expect....maybe something like PageTemplate or soemthing...try
changing your if statement to
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType ==
ListITemType.Al ternateItem)
if that doens't work, like I said, it seem slike something wrong w/your
html..
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"velu" <ve**@discussio ns.microsoft.co m> wrote in message
news:2A******** *************** ***********@mic rosoft.com... 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_ItemC ommand(ByVal source As Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs ) Handles DataGrid1.ItemC ommand
Select Case e.CommandName
Case "rate_it"
If ((e.Item.ItemTy pe <> ListItemType.He ader) And (e.Item.ItemTyp e <> ListItemType.Fo oter)) Then
DocumentID = Convert.ToInt32 (e.Item.Cells(7 ).Text) Dim UserIP As String UserIP = CStr(Request.Us erHostAddress)
Dim comments As String Dim TB As TextBox TB = CType(e.Item.Fi ndControl("Test Box1"), 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.Fi ndControl("Radi oButtonList1"), RadioButtonList ) rate = Request.Form("R adioButtonList1 ")
Dim conPubs As SqlConnection Dim cmdIns As SqlCommand conPubs = New SqlConnection(" server=BGLAMDJV ELU;Database=Pu bs;Integrated security=sspi") cmdIns = New SqlCommand("INS ERT INTO tbl_rating (rating, ip, documentID, usercomment) VALUES (" & rate & " ,'" & UserIP & "'," & DocumentID & ",'" & comments & "');", conPubs) conPubs.Open() cmdIns.ExecuteR eader() conPubs.Close()
End If
End Select
Pls help me I have been working for more than 5 days
Thx Jk
ya i did try to change the if statment but no use. i dont see anything wrong
in the HTML part.
in fact i get value for UserIP and rate DocumentID. some how i need to store
the rate and Comments....
any thoughs ?
"Karl Seguin" wrote: The error seems straighforward. There is no TextBox1 for that item... Check out what e.Item.ItemType is when you get that error...I bet it isn't what you expect....maybe something like PageTemplate or soemthing...try changing your if statement to
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType == ListITemType.Al ternateItem)
if that doens't work, like I said, it seem slike something wrong w/your html..
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ "velu" <ve**@discussio ns.microsoft.co m> wrote in message news:2A******** *************** ***********@mic rosoft.com... 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_ItemC ommand(ByVal source As Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs ) Handles DataGrid1.ItemC ommand
Select Case e.CommandName
Case "rate_it"
If ((e.Item.ItemTy pe <> ListItemType.He ader) And (e.Item.ItemTyp e <> ListItemType.Fo oter)) Then
DocumentID = Convert.ToInt32 (e.Item.Cells(7 ).Text) Dim UserIP As String UserIP = CStr(Request.Us erHostAddress)
Dim comments As String Dim TB As TextBox TB = CType(e.Item.Fi ndControl("Test Box1"), 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.Fi ndControl("Radi oButtonList1"), RadioButtonList ) rate = Request.Form("R adioButtonList1 ")
Dim conPubs As SqlConnection Dim cmdIns As SqlCommand conPubs = New SqlConnection(" server=BGLAMDJV ELU;Database=Pu bs;Integrated security=sspi") cmdIns = New SqlCommand("INS ERT INTO tbl_rating (rating, ip, documentID, usercomment) VALUES (" & rate & " ,'" & UserIP & "'," & DocumentID & ",'" & comments & "');", conPubs) conPubs.Open() cmdIns.ExecuteR eader() conPubs.Close()
End If
End Select
Pls help me I have been working for more than 5 days
Thx Jk
It is possible that TestBox1 is embedded within another control, in this
case you'd need to do
e.Item.FindCont rol("parentCont rol').FindContr ol("TestBox1")
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"velu" <ve**@discussio ns.microsoft.co m> wrote in message
news:D8******** *************** ***********@mic rosoft.com... ya i did try to change the if statment but no use. i dont see anything wrong in the HTML part.
in fact i get value for UserIP and rate DocumentID. some how i need to store the rate and Comments....
any thoughs ?
"Karl Seguin" wrote:
The error seems straighforward. There is no TextBox1 for that item... Check out what e.Item.ItemType is when you get that error...I bet it isn't what you expect....maybe something like PageTemplate or soemthing...try changing your if statement to
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType == ListITemType.Al ternateItem)
if that doens't work, like I said, it seem slike something wrong w/your html..
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ "velu" <ve**@discussio ns.microsoft.co m> wrote in message news:2A******** *************** ***********@mic rosoft.com... > 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_ItemC ommand(ByVal source As Object, ByVal e As > System.Web.UI.W ebControls.Data GridCommandEven tArgs ) Handles > DataGrid1.ItemC ommand > > Select Case e.CommandName > > Case "rate_it" > > If ((e.Item.ItemTy pe <> ListItemType.He ader) And (e.Item.ItemTyp e <> > ListItemType.Fo oter)) Then > > DocumentID = Convert.ToInt32 (e.Item.Cells(7 ).Text) > > > > Dim UserIP As String > UserIP = CStr(Request.Us erHostAddress) > > Dim comments As String > Dim TB As TextBox > TB = CType(e.Item.Fi ndControl("Test Box1"), 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.Fi ndControl("Radi oButtonList1"), RadioButtonList ) > rate = Request.Form("R adioButtonList1 ") > > Dim conPubs As SqlConnection > Dim cmdIns As SqlCommand > conPubs = New > SqlConnection(" server=BGLAMDJV ELU;Database=Pu bs;Integrated > security=sspi") > cmdIns = New SqlCommand("INS ERT INTO tbl_rating (rating, ip, > documentID, > usercomment) VALUES (" & rate & " ,'" & UserIP & "'," & DocumentID & > ",'" > & > comments & "');", conPubs) > conPubs.Open() > cmdIns.ExecuteR eader() > conPubs.Close() > > End If > > End Select > > Pls help me I have been working for more than 5 days > > Thx > Jk >
Yes i did try that
e.Item.FindCont rol("panel1").F indControl("Tes tBox1") still i get "0"
I wonder we are somewere near. :-(
"Karl Seguin" wrote: It is possible that TestBox1 is embedded within another control, in this case you'd need to do e.Item.FindCont rol("parentCont rol').FindContr ol("TestBox1")
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ "velu" <ve**@discussio ns.microsoft.co m> wrote in message news:D8******** *************** ***********@mic rosoft.com... ya i did try to change the if statment but no use. i dont see anything wrong in the HTML part.
in fact i get value for UserIP and rate DocumentID. some how i need to store the rate and Comments....
any thoughs ?
"Karl Seguin" wrote:
The error seems straighforward. There is no TextBox1 for that item... Check out what e.Item.ItemType is when you get that error...I bet it isn't what you expect....maybe something like PageTemplate or soemthing...try changing your if statement to
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType == ListITemType.Al ternateItem)
if that doens't work, like I said, it seem slike something wrong w/your html..
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ "velu" <ve**@discussio ns.microsoft.co m> wrote in message news:2A******** *************** ***********@mic rosoft.com... > 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_ItemC ommand(ByVal source As Object, ByVal e As > System.Web.UI.W ebControls.Data GridCommandEven tArgs ) Handles > DataGrid1.ItemC ommand > > Select Case e.CommandName > > Case "rate_it" > > If ((e.Item.ItemTy pe <> ListItemType.He ader) And (e.Item.ItemTyp e <> > ListItemType.Fo oter)) Then > > DocumentID = Convert.ToInt32 (e.Item.Cells(7 ).Text) > > > > Dim UserIP As String > UserIP = CStr(Request.Us erHostAddress) > > Dim comments As String > Dim TB As TextBox > TB = CType(e.Item.Fi ndControl("Test Box1"), 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.Fi ndControl("Radi oButtonList1"), RadioButtonList ) > rate = Request.Form("R adioButtonList1 ") > > Dim conPubs As SqlConnection > Dim cmdIns As SqlCommand > conPubs = New > SqlConnection(" server=BGLAMDJV ELU;Database=Pu bs;Integrated > security=sspi") > cmdIns = New SqlCommand("INS ERT INTO tbl_rating (rating, ip, > documentID, > usercomment) VALUES (" & rate & " ,'" & UserIP & "'," & DocumentID & > ",'" > & > comments & "');", conPubs) > conPubs.Open() > cmdIns.ExecuteR eader() > conPubs.Close() > > End If > > End Select > > Pls help me I have been working for more than 5 days > > Thx > Jk >
You might need to start debugging your code, simplifying your html and stuff
:)
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"velu" <ve**@discussio ns.microsoft.co m> wrote in message
news:82******** *************** ***********@mic rosoft.com... Yes i did try that
e.Item.FindCont rol("panel1").F indControl("Tes tBox1") still i get "0"
I wonder we are somewere near. :-(
"Karl Seguin" wrote:
It is possible that TestBox1 is embedded within another control, in this case you'd need to do e.Item.FindCont rol("parentCont rol').FindContr ol("TestBox1")
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ "velu" <ve**@discussio ns.microsoft.co m> wrote in message news:D8******** *************** ***********@mic rosoft.com... > ya i did try to change the if statment but no use. i dont see anything > wrong > in the HTML part. > > in fact i get value for UserIP and rate DocumentID. some how i need to > store > the rate and Comments.... > > any thoughs ? > > "Karl Seguin" wrote: > >> The error seems straighforward. There is no TextBox1 for that item... >> Check out what e.Item.ItemType is when you get that error...I bet it >> isn't >> what you expect....maybe something like PageTemplate or >> soemthing...try >> changing your if statement to >> >> if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType == >> ListITemType.Al ternateItem) >> >> if that doens't work, like I said, it seem slike something wrong >> w/your >> html.. >> >> Karl >> >> -- >> MY ASP.Net tutorials >> http://www.openmymind.net/ >> "velu" <ve**@discussio ns.microsoft.co m> wrote in message >> news:2A******** *************** ***********@mic rosoft.com... >> > 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_ItemC ommand(ByVal source As Object, ByVal e As >> > System.Web.UI.W ebControls.Data GridCommandEven tArgs ) Handles >> > DataGrid1.ItemC ommand >> > >> > Select Case e.CommandName >> > >> > Case "rate_it" >> > >> > If ((e.Item.ItemTy pe <> ListItemType.He ader) And (e.Item.ItemTyp e <> >> > ListItemType.Fo oter)) Then >> > >> > DocumentID = Convert.ToInt32 (e.Item.Cells(7 ).Text) >> > >> > >> > >> > Dim UserIP As String >> > UserIP = CStr(Request.Us erHostAddress) >> > >> > Dim comments As String >> > Dim TB As TextBox >> > TB = CType(e.Item.Fi ndControl("Test Box1"), 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.Fi ndControl("Radi oButtonList1"), RadioButtonList ) >> > rate = Request.Form("R adioButtonList1 ") >> > >> > Dim conPubs As SqlConnection >> > Dim cmdIns As SqlCommand >> > conPubs = New >> > SqlConnection(" server=BGLAMDJV ELU;Database=Pu bs;Integrated >> > security=sspi") >> > cmdIns = New SqlCommand("INS ERT INTO tbl_rating (rating, ip, >> > documentID, >> > usercomment) VALUES (" & rate & " ,'" & UserIP & "'," & DocumentID & >> > ",'" >> > & >> > comments & "');", conPubs) >> > conPubs.Open() >> > cmdIns.ExecuteR eader() >> > conPubs.Close() >> > >> > End If >> > >> > End Select >> > >> > Pls help me I have been working for more than 5 days >> > >> > Thx >> > Jk >> > >> >> >> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Arun K |
last post by:
Hi,
I have a RadioButtonList with Active and Inactive List Items (static)
with other textbox fields. When the form is in edit mode i need to get
data from database and show the status checked depending upon db value
(A or I). I was able to bind rest of the the textboxes, but i am unable
to bind this RadioButtonList.
Any thoughts on this ??
|
by: Emil |
last post by:
Can somebody tell me what would be the syntax for having an if statement and
setting the selected index of a radiobuttonlist?
This is my first project using ASP.net and I use C#.
I have a repeater with like a table layout and in the last column I want to
have three radio buttons (for each row in repeater). The value of the radio
button should be calculated from a value from the dataset.
How can I do that? When I try to use a variable...
|
by: Bass Pro |
last post by:
Hi,
I am creating textbox, radiobuttonlist and checkboxlist dynamically
depending on data from a table. It is a questionnaire.
I add the control on a Panel control during the 1st load_page event.
Each question is displayed and answered, then result written to a SQL table.
Then the next question is read from a table and displayed using the
load_page event again.
The questions display and function perfectly. The user anwers the question...
|
by: hanolo |
last post by:
Does anyone ever see this happen.
I build a form with couple of textbox server control. When user inputs
character ` in there, after form post back, the textbox become a line
of string such as <INPUT id=_txtName style="WIDTH: 70%" value=`
name=_txtName>.
I can filter out ` from the inputs, but it seems like a microsoft bug
to me.
|
by: Hugo Flores |
last post by:
Hi,
Here's the situation:
I create a table on run time(Page_Init)
I add a textbox to the first row
I add a RadioButtonList in that same row
The problem is that when I try to get the values that the user selected
from the RadioButtonList I always end up getting the first item
selected. At first my code had the first item selected by default, so I
| |
by: novice_developer |
last post by:
Hi All,
there is a radiobuttonlist having 2 list items (state & zipcode).
when i select state radiobutton the zipcode textbox should be disabled
and when i select a zipcode radiobutton the state textbox should be
disabled. And i need to handle this in client side only.
i'm not able to call a javascript function for radiobuttonlist.
can please some one help me to get out of this...
advance thanks
|
by: Ankit Aneja |
last post by:
code of my aspx page
<asp:RadioButtonList id="RadioButtonList1"
runat="server"></asp:RadioButtonList>
now i want to bind data from database
Dim rsComm As SqlCommand
Dim rsReader As SqlDataReader
|
by: John Meyer |
last post by:
index:
<%@ Page Language="VB" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
|
by: Nathan Sokalski |
last post by:
In the RadioButton and CheckBox controls, there is no Value attribute. The
html <inputtag has a value attribute, which is used by both type="radio"
and type="checkbox". The RadioButtonList and CheckBoxList controls have
SelectedValue properties (I realize that the RadioButtonList uses the
<selectand <optiontags instead of the <inputtag, but needing a value
server-side exists either way). I am attempting to write a control with...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |