Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:21:56+00:00 2026-06-13T17:21:56+00:00

I have a following vb.net function as below in which i am passing a

  • 0

I have a following vb.net function as below in which i am passing a checkbox control name as parameter.Code is here

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

Problem is that i have to use same function with radiobutton also with text box and i don’t want to write separate function for all type of controls.I want to detect the control as parameter and.For Example if i pass text box then function should behave like a text box and if radio then radion behaviour and if checkbox then same behaviour for this.I have these three control to pass the function and i want make a automatic detection method for these controls

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:21:57+00:00Added an answer on June 13, 2026 at 5:21 pm

    You need to send ctrl as CONTROL(its a base class for all controls) as parameter.

    You need to use latebinding and need to write separate cases for each control type….

    Below code will work for checkbox only

    Dim chkbx As CheckBox = CType(gvrow.FindControl(ctrl), CheckBox)
    If chkbx.Checked Then
    

    For textbox and radiobutton you need write additional code

    Public Function emaildata(ByVal grdv As GridView, ByVal ctrl As Control, ByVal celpos As Integer) As GridView
    
     If TypeOf ctrl Is Button Then
    
     ElseIf TypeOf ctrl Is RadioButton Then 
    
     Else
    
     EndIf
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsfiddle.net/yrM3H/2/ I have the following code: jQuery(document).ready(function() { jQuery(.toggle).next(.hidden).hide(); jQuery(.toggle).click(function() { $('.active').toggleClass('active').next('.hidden').slideToggle(300); $(this).toggleClass('active').next().slideToggle(fast); });
I have constructed an ASP.NET user control Box.ascx wtih the following code. <div id=divContent
Say I have a function that does the following in Vb.net For i as
I have following asp.net code but it gives error when I change dropdown selected
I have the following .Net class: public class Product { public int ID {get;set;}
I have the following ADO .Net Repository public class Repository : IRepository, IDisposable {
I have following code that I am compiling in a .NET 4.0 project namespace
I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'
Imagine the following VB.NET class: Public Class P Public Function GetDumbList() As List(Of DumbPeople)
I have the following code in VB.net Dim bytIV() As Byte = {121, 241,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.