Sub - what is the parameter type

A

Arek

I have the sub that is checking if value from the datareader is null. I
would like to pass textbox.text or dropdownbox.selectedvalue as first
parameter and value from data reader as a second parameter.
I cannot figure out what type is first parameter. (I am using ASP since
2 weeks and I don't know where to look for this kind of information)

Below is my sub. I would like to pass textbox.text(or
checkbox.selectedvalue) as objectname and datareader(data) as value.

Private Sub Check_Null(ByVal objectname As System.Object, ByVal value As
Object)
If IsDBNull(value) Then
objectname = ""
Else
objectname = value
Status.Text = objectname
End If

End Sub

Thank you
Arek
 
K

Karl Seguin

WebControl would be your best bet...

if DbNull.Value = value then
value = ""
end if
if typeof(objectName) is TextBox then
ctype(objectName, TextBox).Text = value
else if typeof(objectName) is DropDownList) then
ctype(objectName, DropDownList).SelectedIndex = ...
end if

Karl
 
A

Arek

I modified it a little and now it's working great... I used webcontrol
as you suggested.
If IsDBNull(value) Then
value = ""
End If
If TypeOf (objectname) Is TextBox Then
CType(objectname, TextBox).Text = Convert.ToString(value)
ElseIf TypeOf (objectname) Is DropDownList Then
CType(objectname, DropDownList).SelectedValue =
Convert.ToString(value)
End If
Thank you
Arek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top