Drop Down List

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sajitk
    New Member
    • Feb 2008
    • 77

    Drop Down List

    Dear All,

    I am populating a DDL from a table.

    the DDL gets populated with the list of currency_type. the first value on the list is INR. there are other currency types like INR, USD, EURO etc.

    there are 3 txtboxes which are also on the form. If the selected Item is iNR, then txtbox1 and txtbox2 would be displayed, else txtbox3 is displayed.

    when the form is loaded, if the default value is selected the form is not refreshed. if the other currency type is selected, then it works.

    I want the form to be working when i choose the default value.

    protected void DDLcurrtype_Sel ectedIndexChang ed(object sender, EventArgs e)
    {

    if (DDLcurrtype.Se lectedValue.Tex t ="INR")
    {
    txtExchRate.Ena bled = false;
    txtFC.Enabled = false;
    txtInINR.Enable d = true;
    }
    else
    {
    txtInINR.Enable d = false;
    txtExchRate.Ena bled = true;
    txtFC.Enabled = true;
    }

    Help requested please
  • cloud255
    Recognized Expert Contributor
    • Jun 2008
    • 427

    #2
    Originally posted by sajitk

    when the form is loaded, if the default value is selected the form is not refreshed. if the other currency type is selected, then it works.

    Code:
    protected void DDLcurrtype_SelectedIndexChanged(object sender, EventArgs e)
    Hi,

    Well if you create a break point on the line of code quoted above you will notice that it is not called when the form loads. This is because the SelectedIndexCh anged event is not raised.

    You can manually raise this event when the form loads or place your logic inside a function and call that function when the form loads, you can then also call that function inside the SelectedIndexCh anged event handler.

    I suggest that you encapsulate the logic inside a function as this makes the code more readable and causes a separation of UI and logic, which is a good practice.

    P.S. Please use code tags (# symbol on the toolbar) when posting code, this makes code more readable.

    Comment

    • sajitk
      New Member
      • Feb 2008
      • 77

      #3
      Thanks,

      will take care of using # while pasting codes

      Sajit

      Originally posted by cloud255
      Hi,

      Well if you create a break point on the line of code quoted above you will notice that it is not called when the form loads. This is because the SelectedIndexCh anged event is not raised.

      You can manually raise this event when the form loads or place your logic inside a function and call that function when the form loads, you can then also call that function inside the SelectedIndexCh anged event handler.

      I suggest that you encapsulate the logic inside a function as this makes the code more readable and causes a separation of UI and logic, which is a good practice.

      P.S. Please use code tags (# symbol on the toolbar) when posting code, this makes code more readable.

      Comment

      Working...