博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

从 button列表中获得 commandrgument值

Posted on 2011-07-02 15:27  moss_tan_jun  阅读(250)  评论(0编辑  收藏  举报

 

 

 

<asp:DataList ID="dlTodos" runat="server" RepeatDirection="Horizontal" Visible="false">
                        
<ItemTemplate>
                            
<div style="min-width: 100px">
                                
<div class="Transformation_left">
                                
</div>
                                
<div class="Transformation_middle">
                                    
<asp:LinkButton ID="lnkTodo" runat="server" Text=' <%# Container.DataItem %> ' CommandArgument=' <%# Container.DataItem %> '
                                        OnClick
="lnkTodo_Click " />
                                
</div>
                                
<div class="Transformation_right">
                                
</div>
                            
</div>
                            
<div class="Clear">
                            
</div>
                        
</ItemTemplate>
                        
<SeparatorTemplate>
                            
<div style="width: 50px;">
                            
</div>
                        
</SeparatorTemplate>
                    
</asp:DataList>

 

 protected void lnkTodo_Click(object sender, EventArgs e)
    {
        
//触发事件的Button 
        LinkButton btn = (LinkButton)sender;

        string cmd = btn.CommandArgument;