Sunday, 1 September 2013

ListBox Example

1. Open Visual Studio
2. Create a New Website
3. Create Web Page
4. Place ListBox, TextBox and two Buttons on Page as the shown image below:



5. Add Code to Click Event of Button Add

 protected void Button1_Click(object sender, EventArgs e)
    {
        ListBox1.Items.Add(txtitem.Text);
        txtitem.Text = "";
    }

6. Add Code to Click Event of Button Remove

 protected void Button2_Click(object sender, EventArgs e)
    {
        ListBox1.Items.Remove(ListBox1.Items[ListBox1.SelectedIndex]);
    }

No comments:

Post a Comment

Thanks

SQL server tricky questions