[asp.net][vb] Checking a textbox contains an integer

Associate
Joined
2 Apr 2004
Posts
674
Location
Melbourne
In asp.net using vb how would I go about checking that a textbox contains an integer?

also how do I use the value of a dropdownlist web control, because when I try the following code:

Code:
emp_id = employee.selecteditem.value

it says the following:

Object reference not set to an instance of an object.

when I want to return an integer

I'm confused :confused:
 
Code:
<asp:listbox id="Employee" runat="server" DataValueField="EmployeeId" DataTextField="fullname" Rows="1"></asp:listbox>

I have that as my dropdownlist web control. I'm trying to have a button that when clicked will insert some data into a database, I need to get EmployeeId back to put in the SQL query. I have the following code to do it.

Code:
Sub Button2_Click(sender As Object, e As EventArgs)

    dim emp_id as new integer
    dim sales_no as new integer
    dim salesdate as new date

    emp_id = employee.selecteditem.value
    sales_no = sales.text
    salesdate = calendar1.selecteddate

    'TO DO: build SQL query

End Sub

can you see where I've gone wrong?
 
Back
Top Bottom