change the order of items using dropdownlists
<p>I would like to create the same functionality that Sharepoint provides when you order items using the dropdownlists, as shown in the example below, but I want to create it in asp.net. </p>

<p>Example: when column Modified is selected to be the first one, then values of each dropdowlist is reordered automatically using javascript or jquery. Anyone knows how can I do this? I don't have much experience with javascript so I was looking for some help.</p>

<p>This is what I have so far:</p>

<p>aspx code:</p>

<pre><code>&lt;asp:GridView ID="GridView1" runat="server" EnableModelValidation="True" AutoGenerateColumns="False"
    BorderStyle="Solid" RowStyle-Width="1" RowStyle-BorderWidth="1" RowStyle-BorderColor="silver"
    Width="100%" OnRowEditing="GridView1_RowEditing" 
    onrowcancelingedit="GridView1_RowCancelingEdit" 
    onrowdatabound="GridView1_RowDataBound" DataKeyNames="ID,LanguageID"&gt;
    &lt;Columns&gt;
        &lt;asp:TemplateField HeaderText="Ranking" HeaderStyle-HorizontalAlign="Left" SortExpression="Ranking"&gt;
            &lt;EditItemTemplate&gt;
                &lt;asp:TextBox ID="TextBox4" runat="server" Text='&lt;%# Bind("Ranking") %&gt;'&gt;&lt;/asp:TextBox&gt;
                &lt;asp:DropDownList ID="ddlRanking" runat="server"&gt;
                &lt;/asp:DropDownList&gt;
            &lt;/EditItemTemplate&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:Label ID="Label4" runat="server" Text='&lt;%# Bind("Ranking") %&gt;'&gt;&lt;/asp:Label&gt;
                &lt;asp:DropDownList ID="DropDownList3" runat="server"&gt;
                &lt;/asp:DropDownList&gt;
            &lt;/ItemTemplate&gt;
            &lt;HeaderStyle HorizontalAlign="Left"&gt;&lt;/HeaderStyle&gt;
        &lt;/asp:TemplateField&gt;
    &lt;/Columns&gt;
    &lt;RowStyle BorderColor="Silver" BorderWidth="1px" Width="1px"&gt;&lt;/RowStyle&gt;
&lt;/asp:GridView&gt;
</code></pre>

<p>Code behind:</p>

<pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
    if (e.Row.RowType == DataControlRowType.DataRow) {
        DropDownList ddlLang = (DropDownList)e.Row.FindControl("Dropdownlist2");
        if (ddlLang != null) {
            LanguagesList lang = new LanguagesList();

            ddlLang.DataSource = lang.GetAllByLanguageId();
            ddlLang.DataTextField = "LanguageName";
            ddlLang.DataValueField = "ID";
            ddlLang.DataBind();
            ddlLang.SelectedValue = GridView1.DataKeys[e.Row.RowIndex].Values[1].ToString();
            //ddlLang.Items.FindByValue((Label)(e.Row.FindControl("Label3"))).Selected = true;
        }

        DropDownList ddlRanking = (DropDownList) e.Row.FindControl("Dropdownlist3");
        if(ddlRanking !=null) {
            Ranking(ddlRanking);
        }
    }
}
</code></pre>

<p><img src="http://i.stack.imgur.com/TvJXx.png" alt="enter image description here"></p>

<p>and this is the result from the code above:</p>

<p><img src="http://i.stack.imgur.com/DnU4J.png" alt="enter image description here"></p>
