title: Displaying selected items in dropdowns to a grid view
body: <p>I have 3 dropdowns. when selecting an item from first ddl,second ddl generated with respective items. When selecting second ddl,third ddl generated with respective data. My problem is that when selecting an item from third ddl, 3 items(selected item of 1 ddl,selected item of 2 ddl,selected item of 3 ddl) need to display in a grid view. How to achieve that?
  aspx page:</p>
  
  <pre><code>  &lt;body&gt;
  &lt;form id="form1" runat="server"&gt;
  &lt;asp:DropDownList ID="DDLCountry" runat="server" OnSelectedIndexChanged="DDLCountry_SelectedIndexChanged" AutoPostBack="true"&gt;
      &lt;asp:ListItem&gt;--Select-- &lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;India&lt;/asp:ListItem&gt;
  
      &lt;asp:ListItem&gt;Australia&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;Pakistan&lt;/asp:ListItem&gt;
  
  &lt;/asp:DropDownList&gt;
  &lt;asp:DropDownList ID="DDLState" runat="server" OnSelectedIndexChanged="DDLState_SelectedIndexChanged" AutoPostBack="true"&gt;&lt;/asp:DropDownList&gt;
  &lt;asp:DropDownList ID="DDLCity" runat="server" AutoPostBack="true"&gt;&lt;/asp:DropDownList&gt; 
  
  
  &lt;div&gt;
      &lt;asp:GridView ID="Grd1" runat="server"&gt;
      &lt;/asp:GridView&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p>aspx.cs page</p>
  
  <pre><code>   protected void DDLCountry_SelectedIndexChanged(object sender, EventArgs e)
  {
      DDLCity.Items.Clear();
      DDLState.Items.Clear();
      if (DDLCountry.SelectedIndex == 1)
      {
          DDLState.Items.Add(new ListItem("select", "0"));
          DDLState.Items.Add(new ListItem("Kerala", "1"));
          DDLState.Items.Add(new ListItem("AP", "2"));
          DDLState.Items.Add(new ListItem("Karnataka", "3"));
  
  
  
      }
      else if (DDLCountry.SelectedIndex == 2)
      {
          DDLState.Items.Add(new ListItem("select", "0"));
          DDLState.Items.Add(new ListItem("Victoria", "1"));
          DDLState.Items.Add(new ListItem("Western Australia", "2"));
          DDLState.Items.Add(new ListItem("New South Wales", "3"));
  
  
      }
      else if (DDLCountry.SelectedIndex == 3)
      {
          DDLState.Items.Add(new ListItem("select", "0"));
          DDLState.Items.Add(new ListItem("Balochstan", "1"));
          DDLState.Items.Add(new ListItem("Sindh", "2"));
          DDLState.Items.Add(new ListItem("Punjab", "3"));
  
      }
  
  
  }
  protected void DDLState_SelectedIndexChanged(object sender, EventArgs e)
  {
      DDLCity.Items.Clear();
      if ((DDLCountry.SelectedIndex == 1) &amp;&amp; (DDLState.SelectedIndex == 1))
      {
          DDLCity.Items.Add(new ListItem("Calicut", "0"));
          DDLCity.Items.Add(new ListItem("Kochi", "1"));
  
      }
      else if ((DDLCountry.SelectedIndex == 1) &amp;&amp; (DDLState.SelectedIndex == 2))
      {
          DDLCity.Items.Add(new ListItem("Hyderabad", "0"));
          DDLCity.Items.Add(new ListItem("Vijayawada", "1"));
      }
      else if ((DDLCountry.SelectedIndex == 1) &amp;&amp; (DDLState.SelectedIndex == 3))
      {
          DDLCity.Items.Add(new ListItem("Bengaluru", "0"));
          DDLCity.Items.Add(new ListItem("Mysore", "1"));
      }
      else if ((DDLCountry.SelectedIndex == 2) &amp;&amp; (DDLState.SelectedIndex == 1))
      {
          DDLCity.Items.Add(new ListItem("Melbourne", "0"));
          DDLCity.Items.Add(new ListItem("A", "1"));
      }
      else if ((DDLCountry.SelectedIndex == 2) &amp;&amp; (DDLState.SelectedIndex == 2))
      {
          DDLCity.Items.Add(new ListItem("Perth", "0"));
          DDLCity.Items.Add(new ListItem("B", "1"));
      }
      else if ((DDLCountry.SelectedIndex == 2) &amp;&amp; (DDLState.SelectedIndex == 3))
      {
          DDLCity.Items.Add(new ListItem("Sydney", "0"));
          DDLCity.Items.Add(new ListItem("C", "1"));
      }
     else if ((DDLCountry.SelectedIndex == 3) &amp;&amp; (DDLState.SelectedIndex == 1))
      {
          DDLCity.Items.Add(new ListItem("Lahor", "0"));
          DDLCity.Items.Add(new ListItem("D", "1"));
      }
      else if ((DDLCountry.SelectedIndex == 3) &amp;&amp; (DDLState.SelectedIndex == 2))
      {
          DDLCity.Items.Add(new ListItem("Karachi", "0"));
          DDLCity.Items.Add(new ListItem("E", "1"));
      }
      else if ((DDLCountry.SelectedIndex == 3) &amp;&amp; (DDLState.SelectedIndex == 3))
      {
          DDLCity.Items.Add(new ListItem("Peshawar", "0"));
          DDLCity.Items.Add(new ListItem("F", "1"));
      }
  
  
  }
  </code></pre>