有关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 />
<asp:HyperLink ID= "HyperLink1 " runat= "server " NavigateUrl= ' <%# "imagedetail.aspx?ID= "+DataBinder.Eval(Container.DataItem, "id ")%> ' Target= "_parent "> 详细 </asp:HyperLink>
<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
[解决办法]
<asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%#Eval("id")%>' OnCommand="LinkButton_Command"> 删除 </asp:LinkButton>protected void LinkButton_Command(Object sender, CommandEventArgs e) { Response.Write("You chose: " + e.CommandArgument) ; }