Reputation: 33
This is my ASP Mark Up for radio button list
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:RadioButtonList ID="rbcourse" runat="server" AutoPostBack="True" Height="54px" RepeatDirection="Horizontal" style="text-align: left; font-weight: 700;" Width="385px">
<asp:ListItem >BA</asp:ListItem>
<asp:ListItem>BSC</asp:ListItem>
<asp:ListItem>BSCN</asp:ListItem>
<asp:ListItem>BCOM</asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
this is the markup for hidden field
<asp:HiddenField ID="hffee" runat="server" Value="122" />
this is the sql add parameter value for hffee
cmd.Parameters.AddWithValue("@hffee", Val(hffee.Value))
Now i need if user clicks say on BA radio list item the value of HFFEE which is hidden field and whose value in property is set to nill shall be say 1200 if user selects BSC then the value of hffee shall be 1500 i nut shell i need dynamic value of hidden field which will get stored on sql server on btn submit
i am changing the check box like enable disable checked true false etc on this radio button list on v.b code on the event rbcourse_selected index change which is radio button list i am just writing
Protected Sub rbcourse_SelectedIndexChanged(sender As Object, e As EventArgs) Handles rbcourse.SelectedIndexChanged
If rbcourse.SelectedIndex = "0" Then (0 is the item value of BA)
ge.Checked = True (ge is the text name of check box and it is working)
on that same manner i need
If rbcourse.SelectedIndex = "0" Then (0 is the item value of BA)
then
hffe.value="1200" like this
Upvotes: 1
Views: 1266
Reputation: 1779
This is what I tried and got the fee at button click:
Enum AdmissionFee
BA = 1200
BSC = 1800
BSCN = 2100
BCOM = 2500
End Enum
Protected Sub rbcourse_SelectedIndexChanged(sender As Object, e As EventArgs) Handles rbcourse.SelectedIndexChanged
If rbcourse.SelectedIndex = "0" Then
Me.hffee.Value = Convert.ToString(AdmissionFee.BA)
ElseIf rbcourse.SelectedIndex = "1" Then
Me.hffee.Value = Convert.ToString(AdmissionFee.BSC)
ElseIf rbcourse.SelectedIndex = "2" Then
Me.hffee.Value = Convert.ToString(AdmissionFee.BSCN)
ElseIf rbcourse.SelectedIndex = "3" Then
Me.hffee.Value = Convert.ToString(AdmissionFee.BCOM)
End If
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim fee As Integer
fee = Convert.ToInt32(Me.hffee.Value)
If Me.RdoGender.SelectedIndex = "1" Then
fee += 750
End If
If Me.FE.Checked Then
fee += 110
End If
If Me.dropboard.SelectedIndex > 0 Then
fee += 100
End If
End Sub
Is it what you are looking for?
Upvotes: 1