2
Answers

populate data from listview to radiobutton?

Sakthis

Sakthis

11y
1.1k
1
Hi,

How to populate listview data to radio button like gender column? 

I have listview like id, name, gender, i easily populate id, name respectivly to textbox but i am not sucess when i populate gender(male, female) field to radio button?

can u anyone help me? 

here my code:

  private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem lvi = listView1.SelectedItems[0];
                txtEmpCode.Text = lvi.SubItems[0].Text;
                txtName.Text = lvi.SubItems[1].Text;
                if (Male.Text == "Male") // Male is radio button name
                {
                    Male.Visible = true;
                    Female.Visible = false;
                }
                else if (Female.Text == "Female") // Female is radio button name
                {
                    Male.Visible = false;
                    Female.Visible = true;
                }
            }
            else
            {
                txtEmpCode.Text = string.Empty;
                txtName.Text = string.Empty;               
            }          
        }
Answers (2)