2012-03-09 4 views
0

は私がデータベースから値を示していたにRepeaterコントロールを持っていると私はここのリンクボタンボタンをクリックしてリピータコントロールの並べ替えを行う方法は?

を使用してソート行う必要があり、私のコード

<div class="demo"> 
<ul id="sortable1" class="connectedSortable" style="border-style: groove; border-width: inherit;border-color: #D4D0C8; height: 100%; width: 170px;"> 
<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click" >LinkButton</asp:LinkButton>&nbsp;&nbsp;&nbsp;&nbsp; 
<asp:Repeater ID="rpt1" runat="server" DataSourceID="sqlDataSource1"> 
<ItemTemplate> 
<li class="ui-state-default" > 
<%# DataBinder.Eval(Container.DataItem, "code") %> 
&nbsp;&nbsp; 
<%# DataBinder.Eval(Container.DataItem, "regon_name") %> 
</li> 
</ItemTemplate> 
</asp:Repeater> 
</ul> 
</div> 

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DB_CGTPO_DEVEConnectionString %>" 
SelectCommand="SELECT * FROM [region_test] ORDER BY [code], [regon_name]"></asp:SqlDataSource> 

が任意の提案です?

答えて

1

急速に、あなたはこれらのliknのボタンにイベントを追加し、選択コマンドを変更することができ、このような何か:

public void LinkButton2_Click(object sender, EventArgs e) 
{ 
    //set the new select command with a ordery by 
    SqlDataSource1.SelectCommand = "SELECT * FROM [region_test] ORDER BY [regon_name]"; 

    //refresh the repeater 
    rpt1.DataBind(); 
} 
ヨは、すべてのボタンのイベントを追加し、コマンドにより順序を適用することができ

! このリンクは、(順の状態を保存するためにViewStateを使用して)リピータと同様にそれを行うには良い方法を示しています http://weblogs.asp.net/sushilasb/archive/2004/10/09/240110.aspx

[]の

関連する問題