Here is the solution by phoolchand
namespace WinformswithXml
{
public partial class Form4 : Form
{
string xmlfile = "D:\\phoolchand\\Country.xml";
DataSet ds = new DataSet();
public Form4()
{
InitializeComponent();
}
private void Form4_Load(object sender, EventArgs e)
{
DataView dv,dv1;
ds.ReadXml(xmlfile);
dv = new DataView(ds.Tables[0]);
cboCountry .DataSource = dv;
cboCountry.DisplayMember = "Name";
cboCountry.ValueMember = "Country_Id";
dv1 = new DataView(ds.Tables[1]);
dv1.RowFilter = "Country_Id=" + cboCountry.SelectedValue.ToString();
cbostate.DataSource = dv1;
cbostate.DisplayMember = "SName";
cbostate .ValueMember = "SId";
}
private void cboCountry_SelectedIndexChanged(object sender, EventArgs e)
{
DataView dv1;
dv1 = new DataView(ds.Tables[1]);
string str = cboCountry.SelectedValue.ToString();
if (str != "System.Data.DataRowView" & cboCountry.SelectedIndex != -1)
{
dv1.RowFilter = "Country_Id=" + cboCountry.SelectedValue.ToString();
}
cbostate.DataSource = dv1;
cbostate.DisplayMember = "SName";
cbostate.ValueMember = "SId";
}
}
}