我有一个如下的 vb.net 函数,其中我将复选框控件名称作为参数传递。代码在这里
Public Function emaildata(ByVal grdv As GridView, ByVal ctrl As String, ByVal celpos As Integer) As GridView
Dim comm As OleDbCommand = New OleDbCommand()
Dim bpv As String = ""
Dim gv As New GridView
For Each gvrow As GridViewRow In grdv.Rows
Dim chkbx As CheckBox = CType(gvrow.FindControl(ctrl), CheckBox)
If chkbx.Checked Then
If bpv <> "" Then
bpv += ","
End If
bpv += gvrow.Cells(celpos).Text
comm.CommandText = "SELECT chq_num Cheque#,to_char(bpv_amt,'9,999,999,999') Amount,vch_nar Narration,bnf_nam PartyName,acc_des Bank from CHECK_DATA where bpv_num in(" & bpv.ToString() & ") and BPV_DTE=to_date('" & TreeView2.SelectedValue & "')"
comm.CommandType = CommandType.Text
comm.Connection = con
Dim da As New OleDbDataAdapter(comm)
Dim ds As New DataSet
da.Fill(ds)
gv.DataSource = ds
gv.DataBind()
End If
Next
Return gv
End Function
问题是我必须使用与单选按钮相同的功能也与文本框,我不想为所有类型的控件编写单独的函数。我想将控件检测为参数和。例如,如果我传递文本框然后函数应该表现得像一个文本框,如果是单选,那么是单选行为,如果是复选框,那么这个行为是一样的。我有这三个控件来传递函数,我想为这些控件创建一个自动检测方法