日期:2014-05-18  浏览次数:20407 次

repeater中button的用法
我在repeater中放了一个button,我想实现在点某条记录前的button的同时让这个button的text='选中'。请问这个如何实现。
还有各位大侠有没有repeater中使用其他各种控件的实例或文章,能整合在一起的最好了。3Q。

------解决方案--------------------
repeater
------解决方案--------------------
<input type="button" onclick="this.value='选中'" value="点我"/> 不晓得对否?
------解决方案--------------------
探讨

<input type="button" onclick="this.value='选中'" value="点我"/> 不晓得对否?

------解决方案--------------------
C# code

<asp:Repeater ID="rpt" runat="server">
   <ItemTemplate>
           <asp:Button ID="btn" runat="server" Text="按钮" OnCommand="btn_Command"/>
   </ItemTemplate>
</asp:Repeater>

后台cs文件
public void btn_Command(object sender,CommandEventArgs e)
{
    Button btn = sender as Button;
    btn.Text = "选中";
}

------解决方案--------------------
C# code


protected void Repeater1_ItemCommand(object sender, RepeaterItemEventArgs e)
{
  if(e.commandName=="button1")
   
  { 
     button bt= e.Item.FindControl("button1") as Button;
    if(bt.text=="选中") 
     
   {
                  bt.text="未选中";
    }

    else
    {
 bt.text="选中";


   }
}

------解决方案--------------------
HTML code
<asp:Button ID="btn" runat="server" Text="点我" onclick="if(this.value=='选中')this.value='未选中';else{this.value='选中';}"/>