日期:2014-05-19  浏览次数:20650 次

有关datalist获取当前行的问题
我要在点击删除连接 <asp:LinkButton   ID= "LinkButton1 "   runat= "server "   OnClick= "LinkButton1_Click "> 删除 </asp:LinkButton> 的时候,如何获取当前行的值?


<body>
        <form   id= "form1 "   runat= "server ">
        <div>
                <asp:DataList   ID= "DataList1 "   runat= "server "   CellSpacing= "8 "  
                        RepeatColumns= "4 "   RepeatDirection= "Horizontal "   DataSourceID= "AccessDataSource1 "   DataKeyField= "id ">
                        <ItemTemplate>
                                <asp:Image   ID= "Image1 "   runat= "server "   Height= "152px "   ImageUrl= ' <%#   Eval( "name ")   %> '
                                        Width= "156px "   /> <br   />
                                &nbsp;   &nbsp;   &nbsp;   &nbsp;   &nbsp; <asp:HyperLink   ID= "HyperLink1 "   runat= "server "   NavigateUrl= ' <%# "imagedetail.aspx?ID= "+DataBinder.Eval(Container.DataItem, "id ")%> '   Target= "_parent "> 详细 </asp:HyperLink> &nbsp;
                                <asp:LinkButton   ID= "LinkButton1 "   runat= "server "   OnClick= "LinkButton1_Click "> 删除 </asp:LinkButton>
                           
                           
                               
                        </ItemTemplate>
                </asp:DataList> <asp:AccessDataSource   ID= "AccessDataSource1 "   runat= "server "   DataFile= "~/student.mdb "
                        SelectCommand= "SELECT   [name],   [id]   FROM   [postimage]   ORDER   BY   [time]   DESC "> </asp:AccessDataSource>
                </div>
        </form>
</body>

------解决方案--------------------
e.Item.ItemIndex
------解决方案--------------------
HTML code
<asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%#Eval("id")%>' OnCommand="LinkButton_Command"> 删除 </asp:LinkButton>

protected  void LinkBu