Sub - what is the parameter type

  • Thread starter Thread starter Arek
  • Start date Start date
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
 
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
 
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
 
Back
Top