Q:

GridView Asp .Net-Changing the selected value of a second drop down list based on value of first drop Down in same column

I'm new to ASP.NET and C#.  I have a Grid View With Drop-Down-list. For Instance if the Grid View is like this,
<! DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="`server`">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Designation" HeaderText="Designation" SortExpression="Designation" />
                <asp:TemplateField HeaderText="City">
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="City" DataValueField="City">
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CS %>" SelectCommand="SELECT [City] FROM [EmployeeDetails]"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CS %>" SelectCommand="SELECT [ID], [Name], [Designation] FROM [EmployeeDetails]"></asp:SqlDataSource>
    </form>

And In Column City,If suppose I select Mumbai in first DropDown, I want rest of the Dropdownlists in the column City to automatically change to Mumbai. 
How to do that? 

A:

Change as below in you aspx file,
<asp:DropDownList ID="DropDownList1" runat="server"  DataTextField="City" DataValueField="City" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">

In you aspx.cs file,
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList selectedDropDown = (DropDownList)sender;
        foreach(GridViewRow gRow in GridView1.Rows)
        {
            DropDownList ddlCity = (DropDownList)gRow. FindControl("DropDownList1");
            ddlCity. SelectedValue = selectedDropDown. SelectedValue;
        }
    }

This should work for all the drop down. 
If you want it to work only for First Dropdown then, Use the condition as below. 
if (((GridViewRow)selectedDropDown. Parent. Parent).RowIndex == 0)
        {
            foreach (GridViewRow gRow in GridView1.Rows)
            {
                DropDownList ddlCity = (DropDownList)gRow. FindControl("DropDownList1");
                ddlCity. SelectedValue = selectedDropDown. SelectedValue;
            }
        }

