Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
A form with the undernoted


1. Disbursement Type (ddl) : ddl_Disburs_Type (Text)

2. Amount Approved : txt_Expect_Amt (Text)

3. Actual Disbursement : txt_Actual_Disb (Text)


The Drill down (i.e. Disbursement Type) has 2 items a. FULL b. TRANCHE

When the option FULL is selected the program has to do the following .

However control does not switch over.

please assist


C#
protected void ddl_Disburs_Type_SelectedIndexChanged(object sender, EventArgs e)
     {

         if (ddl_Disburs_Type.Text == "FULL")
         {

             txt_Tranche.Text = "0";
             txt_Tranche.Enabled = false;
             txt_Actual_Disb.Text = txt_Expect_Amt.Text;

             decimal KExpect_Amt = Convert.ToDecimal(txt_Expect_Amt.Text);
             txt_Expect_Amt.Text = KExpect_Amt.ToString("N");

             //decimal KActual_Disb = Convert.ToDecimal(txt_Actual_Disb.Text);
             decimal KActual_Disb = Convert.ToDecimal(txt_Expect_Amt.Text);
             txt_Actual_Disb.Text = KActual_Disb.ToString("N");
Posted

Did you try to debug your code? That should give you a clear idea why it does not work.

Look on MSDN, how to debug ASP.Net Apps using VS:

http://msdn.microsoft.com/en-us/library/w2faa92k.aspx[^]

On another note, it's always good to compare string irrespective of casing in such situations.

And also, I would also put FULL in constant or a resource string instead of a magic string[^].

C#
if(String.Compare(ddl_Disburs_Type.Text, const_resource_Full, true) == 0)
{
    //you logic here
}
 
Share this answer
 
Comments
DamithSL 16-Nov-14 5:32am    
good advices,my 5+
I have added another answer to this question because if postback never happened OP can't debug.
Manas Bhardwaj 16-Nov-14 5:37am    
thx!
apart from Manas Answer, in ASP.NET DropDownList [^]is not postback on selected item change by default. Even you have added SelectedIndexChanged [^]event to your DropDownList it will not excute it unless you set the AutoPostBack [^]Property as true. Sample code :
<asp:dropdownlist id="ColorList" xmlns:asp="#unknown">
                   AutoPostBack="True"
                   OnSelectedIndexChanged="Selection_Change"
                   runat="server"></asp:dropdownlist>

After you set above property, put break point inside the event handler and run the web application. You can check what is the value you receive as Text property of the DropDownList. According to that you can change the code or it will help you to find solution for why your code block not functioning as you expected.
additional learning resources for debugging if you interested:
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Advanced Debugging in Visual Studio[^]
 
Share this answer
 
Comments
Manas Bhardwaj 16-Nov-14 5:37am    
agree +5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900