给DataList的e.Item审核通过。出错了,数据ID怎么绑定?
本帖最后由 woyaodubo 于 2013-12-24 11:55:30 编辑 多行多列的,DataKeys[e.ItemIndex]不行吧。用了DataKeys[e.Item.ItemIndex]也不行。
应该怎样绑定呢?
<asp:DataList ID="DataList1" runat="server" RepeatColumns="2">
<ItemTemplate>
<asp:LinkButton ID="lkbImg" runat="server">
<img src='/Student/UpSmallPhoto/<%# Eval("Photo_Path")%>' style="border-width:0px" width="133px" height="100px"/>
</asp:LinkButton>
<asp:LinkButton ID="pass" style="text-decoration:none;color:#ff0000;" runat="server" Text="审核通过" OnClick="pass_Click"/>
</ItemTemplate>
</asp:DataList>
protected void pass_Click(object sender, EventArgs e)
{
string passSql = "update Stu_Work set Pass='1' where Work_ID='" + DataList1.DataKeys[e.Item.ItemIndex].ToString() + "'";
bool del = mydata.ExceSQL(passSql);
if (del)
{
Response.Write("<script language=javascript>alert('通过审核');</script>");
}
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
Literal ID = (Literal)e.Item.FindControl("ltID");
switch (e.CommandName)
{
case "Approve":
Response.Write(e.Item.ItemIndex);
break;
default: break;
}
}