You must Sign In to post a response.
  • Category: Windows 8

    Dropdown list value not getting displayed in output

    Hi,

    Please go through the snippets and let me know where actually mistake is

    In the below code, all the values are getting dispalyed except Citylist value. I have run debug mode and the selected CityList value was passed to String.Format but it is not getting printed or dispalyed in output

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    CityList.Items.Add("----Please Select----");
    CityList.Items.Add("Chennai");
    CityList.Items.Add("Madurai");
    CityList.Items.Add("Tirunelveli");
    }
    }

    protected void btntxtbox_Click(object sender, EventArgs e)
    {
    string Name = nametxtbox.Text;
    string age = agetxtbox.Text;
    string email = emailtxtbox.Text;
    lblresult.Text += String.Format
    (" Name = {0} <br/> Age ={1} <br /> Email = {2} <br / City ={3}>",
    Name,
    age,
    email,
    CityList.SelectedItem.Text);
    }
  • #767810

    Hai Boopa,
    Looks like you have wrongly places the < br / > closing tag.
    Please find below working code:

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    CityList.Items.Add("----Please Select----");
    CityList.Items.Add("Chennai");
    CityList.Items.Add("Madurai");
    CityList.Items.Add("Tirunelveli");
    }
    }
    protected void btntxtbox_Click(object sender, EventArgs e)
    {
    lblresult.Text = string.Empty;

    string Name = nametxtbox.Text;
    string age = agetxtbox.Text;
    string email = emailtxtbox.Text;
    lblresult.Text = String.Format("Name = {0}, <br/> Age ={1}, <br /> Email = {2}, <br /> City ={3}",
    Name,
    age,
    email,
    CityList.SelectedItem.Text);
    }

    Hope it will be helpful to you.


    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #767815
    Yes, you are correct. Learning codings and thank you very much for your time and reply.


Sign In to post your comments