I have a page where user will select an item from RadioButtonList . When the user click next button, in the next page (this page has a GridView with 32 rows. Each row has a description - comes from database table and 3 textboxes) the depending on what he selected, textboxes from all 32 rows will either be enabled or disabled. That is if for example he selected Employee list item, all textboxes associated with employee in page 2 will be enabled. The other 2 will be read only. Then the user can enter a number on enabled textboxes. I also want to calculate Grand Total cost (each row is a service with cost in a table in database)for the services. This will be all textboxes the user entered a number multiplied by the cost of each service. I want to show that total in a different page when the user click next button.
I want to use session because nothing will be saved in the database. How do I do this?
Code for RadioButtonList in PersonalFactors .aspx page
Codebehind for PersonalFactors .aspx page
Code for Service.aspx page
Codebehind for Service.aspx page
I want to use session because nothing will be saved in the database. How do I do this?
Code for RadioButtonList in PersonalFactors .aspx page
Code:
<asp:RadioButtonList ID="chkPlanCategoryList" runat="server"
AutoPostBack="True">
<asp:ListItem Text="Employee only" Value="0" />
<asp:ListItem Text="Employee Plus Child(ren)" Value="1" />
<asp:ListItem Text="Employee Plus Spouse" Value="2" />
<asp:ListItem Text="Family" Value="3"/>
</asp:RadioButtonList>
Code:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Public Class PersonalFactors
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session("parm") = chkPlanCategoryList.SelectedValue
End Sub
Protected Sub btnNext_Click(sender As Object, e As System.EventArgs) Handles btnNext.Click
Dim str As String = chkPlanCategoryList.SelectedItem.Text
'Response.Redirect("Result.aspx?parm=" & str)
'Response.Redirect("Service.aspx?parm=" & str)
End Sub
Protected Sub btnBack_Click(sender As Object, e As System.EventArgs) Handles btnBack.Click
Response.Redirect("Home.aspx")
End Sub
End Class
Code:
<div id="container">
<div id="header">Employee Estimated Annual Medical Usage</div>
<div id="instructions">
Enter the number of times you or people in your family will use
the following medical services during the year. When finished click next button to continue.
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" Width="957px" GridLines="Vertical"
CellPadding="3" BackColor="White" BorderColor="#999999" BorderStyle="None"
BorderWidth="1px">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:TemplateField HeaderText="Medical Service Description"
SortExpression="hcs_Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("hcs_Description") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("hcs_Description") %>'></asp:Label>
</ItemTemplate>
<ControlStyle CssClass="smalllabel" />
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Employee">
<ItemTemplate>
<asp:TextBox ID="txtEmployee" runat="server" maxlength="2" size="3" class="numberinput"></asp:TextBox>
<cc2:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server"
FilterType="Numbers" TargetControlID="txtEmployee" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Spouse">
<ItemTemplate>
<asp:TextBox ID="txtSpouse" runat="server" maxlength="2" size="3" class="numberinput"></asp:TextBox>
<cc2:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server"
FilterType="Numbers" TargetControlID="txtSpouse" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Child">
<ItemTemplate>
<asp:TextBox ID="txtChild" runat="server" maxlength="2" size="3" class="numberinput"></asp:TextBox>
<cc2:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server"
FilterType="Numbers" TargetControlID="txtChild" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BorderStyle="Groove" BackColor="#000084" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BorderStyle="Groove" CssClass="grayservicebackground"
BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString3 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString3.ProviderName %>"
SelectCommand=" SELECT hcs_Description, hcs_Employee, hcs_Spouse, hcs_Child FROM [HealthCareEstimator].[hce].[HealthCareService]" >
</asp:SqlDataSource>
</div>
Code:
Public Class Service
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim txtemployee As TextBox = CType(e.Row.FindControl("txtemployee"), TextBox)
Dim txtspouse As TextBox = CType(e.Row.FindControl("txtspouse"), TextBox)
Dim txtChild As TextBox = CType(e.Row.FindControl("txtchild"), TextBox)
Select Case Session("parm")
Case "0" ' Employee only
txtemployee.Visible = True
txtspouse.Visible = False
txtChild.Visible = False
Case "1" ' Employee Plus Child(ren)
txtemployee.Visible = True
txtspouse.Visible = False
txtChild.Visible = True
Case "2" ' Employee Plus Spouse
txtemployee.Visible = True
txtspouse.Visible = True
txtChild.Visible = False
Case "3" ' Family
txtemployee.Visible = True
txtspouse.Visible = True
txtChild.Visible = True
End Select
End If
End Sub
Protected Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
Response.Redirect("~/Users/EstimatedHealthBenefitCost")
End Sub
End Class