I have some fields like that
Mode : Credit, Debit
Account : ABC Account
Balance: 5000
Payment: 0
Balance: 0
If I select the mode Credit then result should be like that
Mode : Credit
Account : ABC Account
Balance: 5000
Payment: 1000
Total: 6000
If I select the mode Debit then result should be like that
Mode : Debit
Account : ABC Account
Balance: 5000
Payment: 1000
Total: 4000
<div class="col-sm-3">
<label class="control-label" style="margin-top: 10px;">
Type</label>
<asp:DropDownList ID="ddlType" runat="server"
class="validate[required] form-control"
onselectedindexchanged="ddlType_SelectedIndexChanged" AutoPostBack="false">
<asp:ListItem> ---Select One--- </asp:ListItem>
<asp:ListItem> Credit </asp:ListItem>
<asp:ListItem> Debit </asp:ListItem>
</asp:DropDownList>
</div>
<div class="col-sm-3">
<label class="control-label" style="margin-top: 10px;">
Select Account
</label>
<asp:DropDownList ID="ddlAcc" runat="server" class="validate[required] form-control"
AutoPostBack="true" OnSelectedIndexChanged="ddlAcc_SelectedIndexChanged">
</asp:DropDownList>
</div>
<div class="col-sm-3">
<label class="control-label" style="margin-top: 10px;">
Balance
</label>
<asp:TextBox ID="txtPay" runat="server" class="form-control" Text="0"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<label class="control-label" style="margin-top: 10px;">
Amount</label>
<asp:TextBox ID="txtCredit" runat="server" class="form-control" Text="0" OnTextChanged="txtCredit_TextChanged"
AutoPostBack="true" ></asp:TextBox>
</div>
<div class="col-sm-3">
<label class="control-label" style="margin-top: 10px;">
Total Balance
</label>
<asp:TextBox ID="txtDesc" runat="server" class="form-control" placeholder="Description"></asp:TextBox>
</div>
protected void txtCredit_TextChanged(object sender, EventArgs e)
{
double Amount = Convert.ToInt64(txtPay.Text);
double Credit = Convert.ToInt64(txtCredit.Text);
if (ddlType.SelectedItem.Value.ToString() == "Credit")
{
double Sum = Convert.ToInt64(Amount + Credit);
txtDesc.Text = Sum.ToString();
}
if (ddlType.SelectedItem.Text.ToString() == "Debit")
{
double Sub = Convert.ToInt64(Amount - Credit);
txtDesc.Text = Sub.ToString();
}
//Response.Write(ddlType.SelectedItem.Value.ToString());
}
it is not showing any value. how to get solution pls.