radio button checked and not checked at same time

Status
Not open for further replies.

deepakgates

Broken In
okay then ....
im making dynamic sql statement
rmode is a radio button and tmode is a combo box



Private Sub bsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bsearch.Click

If rmode.Checked = True Then
ElseIf tmode.SelectedIndex = 0 Then
sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
ElseIf tmode.SelectedIndex = 1 Then
sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
End If



If rmode.Checked = True Then
MsgBox("mode")

End If






con.Open()
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "licdb")
con.Close()
datagridresult.DataSource = ds.Tables("licdb").DefaultView
End Sub


im facing a hell of a problem
do u see two if statement
just one get executed

the second one... if i put only second then it gets executed and if only first then nothing gets executed..

WHYYYYYYYYYYYYYYYY????

PS: radiobutton is checked!!
 
OP
deepakgates

deepakgates

Broken In
You are a genius....
You did it

It worked

But please tell me why it worked and what was the problem earlier...i want to know!!


am using vs2008
 

ruturaj3

Journeyman
try this,

If rmode.Checked = True Then

If tmode.SelectedIndex = 0 Then
sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
End If
If tmode.SelectedIndex = 1 Then
sql = "SELECT * FROM licdata WHERE Mode = '" & tmode.Text & "'"
End If

End If
 

abhijangda

Padawan
You are a genius....
You did it

It worked

But please tell me why it worked and what was the problem earlier...i want to know!!


am using vs2008

it is simple dude
u said that radio button is selected.
But in IF command u use ELSEIF
which will be executed only when radio button is not selected. that's why.
thx for calling me genius:-D.
 
Status
Not open for further replies.
Top Bottom