首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

有关datalist获取当前行的有关问题

2012-01-07 
有关datalist获取当前行的问题我要在点击删除连接 asp:LinkButtonID LinkButton1 runat server OnC

有关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 LinkButton_Command(Object sender, CommandEventArgs e)    {        Response.Write("You chose: " + e.CommandArgument) ;    } 

热点排行