如何获取Repeater以绑定的字段的某一行的值?

2024-12-20 00:36:00
推荐回答(2个)
回答1:

                
                    
                        
                            编号
                        
                        
                            名称
                        
                        
                        连接类型
                        
                        
                            URL
                        
                        
                            排序
                        
                        
                            显示
                        
                        
                            编辑
                        
                        
                            删除
                        
                    
                    
                        
                            
                                
                                    <%# Eval("ID") %>
                                
                                
                                    <%# Eval("Name") %>
                                
                                                                
                                   <%# Enum.Parse(typeof(Model.KeenEnum.LinkType), Eval("Type").ToString()) %>
                                
                                
                                    ' target="_blank" title=' <%# Eval("Name") %>'>
                                        <%# Eval("URL") %>
                                
                                
                                    <%# Eval("Order") %>
                                
                                
                                    <%# Eval("State").ToString() == "1" ? "是" : "否"%>
                                
                                
                                    '>编辑
                                
                                
                                                                            CommandArgument='<%#Eval("ID")%>' runat="server">删除
                                
                            
                        

                    
                
    protected void rptLink_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            if (lkBLL.Delete(e.CommandArgument.ToString()))
            {
                MessageBox.Show(this.Page, "删除成功!");
                BindData();
            }
            else
            {
                MessageBox.Show(this.Page, "删除失败!");
                return;
            }
        }
    }

注意要绑定事件: OnItemCommand="rptLink_ItemCommand"

回答2:

前台绑定CommArgs在后台的Comm事件中获取e.CommArgs