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

<asp:RepeaterID="rp1"runat="server"onitemdatabound="rp1_ItemDataBound"><ItemTemplate>... <asp:Repeater ID="rp1" runat="server" onitemdatabound="rp1_ItemDataBound">
<ItemTemplate>
<tr onmouseover="this.style.backgroundColor='#eafcd5'" onmouseout="this.style.backgroundColor='#ffffff'" bgcolor="#ffffff">
<td height="22" ><div align="center" class="STYLE1"><%#Eval("YongHuMing")%></div></td>
<td><div align="center" class="STYLE1"><%# Eval("QuanXian")%></div></td>
<td><div align="center" class="STYLE1"><%# Eval("WenTi")%></div></td>
<td><div align="center" class="STYLE1"><asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="return confirm('确认要删除此行信息吗?')" OnClick="LinkButton1_Click">删除</asp:LinkButton></div></td>
</tr>
</ItemTemplate>
</asp:Repeater>
数据是以表格的形式显示在页面上的。
我想在LinkButton1_Click事件中实现某一行的删除,要获取这一行的YongHuMing字段的值,请问在后台怎么实现?
展开
 我来答
suqifeng2009
推荐于2016-04-03 · TA获得超过103个赞
知道小有建树答主
回答量:127
采纳率:0%
帮助的人:77.4万
展开全部
                <table class="tablecontent">
                    <tr>
                        <th>
                            编号
                        </th>
                        <th>
                            名称
                        </th>
                        <th>
                        连接类型
                        </th>
                        <th>
                            URL
                        </th>
                        <th>
                            排序
                        </th>
                        <th>
                            显示
                        </th>
                        <th>
                            编辑
                        </th>
                        <th>
                            删除
                        </th>
                    </tr>
                    <asp:Repeater runat="server" ID="rptLink" OnItemCommand="rptLink_ItemCommand">
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <%# Eval("ID") %>
                                </td>
                                <td>
                                    <%# Eval("Name") %>
                                </td>
                                                                <td>
                                   <%# Enum.Parse(typeof(Model.KeenEnum.LinkType), Eval("Type").ToString()) %>
                                </td>
                                <td>
                                    <a href='<%# Eval("URL") %>' target="_blank" title=' <%# Eval("Name") %>'>
                                        <%# Eval("URL") %></a>
                                </td>
                                <td>
                                    <%# Eval("Order") %>
                                </td>
                                <td>
                                    <%# Eval("State").ToString() == "1" ? "<span style='color:#00F' >是</span>" : "<span style='color:#F00' >否</span>"%>
                                </td>
                                <td>
                                    <a href='LinkEdit.aspx?id=<%# Eval("ID") %>'>编辑</a>
                                </td>
                                <td>
                                    <asp:LinkButton ID="lkbtnDelete" OnClientClick="return confirm( '您确认要删除吗? ') ;" CommandName="Delete"
                                        CommandArgument='<%#Eval("ID")%>' runat="server">删除</asp:LinkButton>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </table>
    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"

丶没好名字
2013-09-22 · TA获得超过143个赞
知道小有建树答主
回答量:374
采纳率:0%
帮助的人:231万
展开全部
前台绑定CommArgs在后台的Comm事件中获取e.CommArgs
追问
大神能不能详细点,前台绑定CommArgs怎么做,后台又怎么做?我没做过,是在不知道……
追答
CommandArgument=''前台在你的LinkButton上面绑定下这个,如果有2个LinkButton还需要绑定CommandName,方便识别是那个按钮点击
后台:
protected void btn_Cancel(object sender, CommandEventArgs e)绑定事件
获取e.CommandArgument,这个就是获取你绑定的值
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式