Radio button question

S

Steve Chatham

I have a combo box that gets populated with a group of items based on a sql
table.

I had in mind that I'd insert a value at the beginning of that combo box,
that'd say "No Item Selected" and that when the selected index property was
changed, to automatically populate a datagrid below that combo box based on
the item selected.

As an alternative, if the user wanted to see everything (a customer list), I
wanted to put a radio button there that would give them everything when they
clicked on it.

However, it appears that there's no onclick event tied to a radio button.
There's a _checkchanged property that appears to do nothing. In it, I have
in addition to the sql and bindgrid command, commands to hide the combo box
if they want all items. That doesn't appear to work.

Is there another/better way to do this?

My intention of doing it this way was to let them choose between everything
and a restricted list, and make it obvious that they did not have to use the
combo box or have a submit button above to make the application run the
query and show the appropriate data.

I'm using VB & ASP.net.

Thanks,

SC
 
S

Scott M.

CheckChanged is the event that does fire when a RadioButton's check gets
changed. You should test the code that you have in that event because this
event will fire when the RadioButton is clicked. Although, if there is only
one choice, you may want to consider using a checkbox instead of a
radiobutton as radiobuttons are typically used to pick one item from a
series of choices and checkboxes can be used for just one possible
selection.
 
C

Chad Z. Hower aka Kudzu

Steve Chatham said:
As an alternative, if the user wanted to see everything (a customer
list), I wanted to put a radio button there that would give them
everything when they clicked on it.

However, it appears that there's no onclick event tied to a radio
button. There's a _checkchanged property that appears to do nothing. In
it, I have in addition to the sql and bindgrid command, commands to hide
the combo box if they want all items. That doesn't appear to work.

Is there another/better way to do this?

If there is no onclick event you will have to resort to Javascript to trigger
a server side event. There is a Javascript event you can use to catch this.

If you are open to third party components, I can recommend one that has radio
buttons with OnClick events.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
 
S

Steve Chatham

It appears that the checkbox does the same thing - nothing.

Here's the code I have for each of those 2 things:

Private Sub rbAllChannels_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles rbAllChannels.CheckedChanged

lblDC.Visible = False

cmbChannel.Visible = False

DataGrid1.Visible = True

ss = "select ssoldto, sshipto, ssalesgrp, ssalesrep, sdistrchnl, scustname1,
sstreet, scity, sstate, szip_code, stelephone from tblmaster_shipto "

ss = ss & " group by ssoldto, sshipto, ssalesgrp, ssalesrep, sdistrchnl,
scustname1, sstreet, scity, sstate, szip_code, stelephone order by
scustname1"

BindGrid()

End Sub


Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles CheckBox1.CheckedChanged

lblDC.Visible = False

cmbChannel.Visible = False

DataGrid1.Visible = True

ss = "select ssoldto, sshipto, ssalesgrp, ssalesrep, sdistrchnl, scustname1,
sstreet, scity, sstate, szip_code, stelephone from tblmaster_shipto "

ss = ss & " group by ssoldto, sshipto, ssalesgrp, ssalesrep, sdistrchnl,
scustname1, sstreet, scity, sstate, szip_code, stelephone order by
scustname1"

BindGrid()

End Sub


I was expecting it to fire the code I have below each one of those whenever
I clicked the radio button or the checkbox. It just sits there.

SC
 
S

Steve Chatham

Yes - right now open to suggestions as to how to accomplish this. Third
party components may be the way to go.

Thanks,

SC
 
C

Chad Z. Hower aka Kudzu

Scott M. said:
CheckChanged is the event that does fire when a RadioButton's check gets
changed. You should test the code that you have in that event because
this event will fire when the RadioButton is clicked. Although, if

Does this cause a submit though? or only get fired during a submit caused by
another control?
 
S

Steve Chatham

<<CheckChanged is the event that does fire when a RadioButton's check gets
Does this cause a submit though? or only get fired during a submit caused by
another control?>>


I believe it does not cause a Submit, which is what I thought it ought to
do.

SC
 
C

Chad Z. Hower aka Kudzu

Steve Chatham said:
I believe it does not cause a Submit, which is what I thought it ought to
do.

Thats what I suspected. The user definitely wants a submit in this case.
 
C

Chad Z. Hower aka Kudzu

Steve Chatham said:
Yes - right now open to suggestions as to how to accomplish this. Third
party components may be the way to go.

The javascript required if you choose to do it yourself would not be pretty.

IntraWeb has radio groups that have OnClick events that do cause a submit,
and will allow you to do exactly what you want. Im sure if you give it a try
you can figure it out in about 10 seconds, but if you want me to write some
code or demos for you I'd be happy to.

One small "gotcha" though. IntraWeb is an add on to ASP.net, but its not an
add on in the sense that it just gives you a new control you can drop in. Its
controls are "smart" controls and thus must go on an IntraWeb "WebForm". But
you can mix and match IntraWeb forms with ASP.net forms - it is just an
extension to ASP.net.

http://www.atozed.com/intraweb/

It also has a free eval, with no expiration.
 
S

Scott M.

All you need to do is set the CheckBox's or RadioButton's "AutoPostBack"
property to true to cause it to submit back to the server and trigger its
CheckChanged event on the next page delivery.

No 3rd party tool needed.
 
C

Chad Z. Hower aka Kudzu

Scott M. said:
All you need to do is set the CheckBox's or RadioButton's "AutoPostBack"
property to true to cause it to submit back to the server and trigger its
CheckChanged event on the next page delivery.

"on next page delivery". Does AutoPostBack cause it to do a submit when
clicked? or does it still wait for some other control to cause a submit?
 
S

Scott M.

AutoPostBack causes a submit (or PostBack).

So, the page data will be submitted and then as the page does its postsback,
it will fire the CheckChanged event of the checkbox (or radiobuton).
 
S

Steve Chatham

The "cheap" fix worked. The Autopostback does what I wanted it to do.

The one thing that I do not like about trying to code in dot net is that
sometimes what seems to ought to be obvious, easy-to-do things can turn into
some of the most time consuming, frustrating tedious activities. Mostly
because the way to do it is "hidden in plain sight".

Thanks again, both of you for the assistance.

SC
 
S

Scott M.

Your welcome Steve. Let me just say that I know exactly how you feel as
this is how I felt when I moved to .NET (came from a VB 6.0/Classic ASP
background). But, after a while, you begin to change your mindset and get a
better grip on just what's happening in the .NET architecture.

Give it some time.

Scott
 

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
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top