<asp:Repeater ID="rpt1" runat="server" onitemdatabound="rpt1_ItemDataBound"
onitemcommand="rpt1_ItemCommand" >
<ItemTemplate>
<tr height="25" align="left" valign="middle" bgcolor="#ffffff" name="discolorationline">
<td align="center">
<%# DataBinder.Eval(Container.DataItem,"type")%>
</td>
<td style="display:none;"><%# DataBinder.Eval(Container.DataItem, "project_target_id")%></td>
<td>
<table id="tb2" frame="void" cellspacing="1" cellpadding="0" border="0" bgcolor="#95a5d2" width="995">
<asp:Repeater ID="rpt2" runat="server">
<ItemTemplate>
<tr height="25" align="left" valign="middle" bgcolor="#ffffff" name="discolorationline">
<td align="center" width ="630">
<%# Eval("content") %>
</td>
<td align="center" width="60">
<%# Eval("weight") %>
</td>
<td align="center" width="60">
<%# Eval("score") %>
</td>
<td align="center" width="175">
<%# Eval("remark") %>
</td>
<td align="center" width="60">
<asp:ImageButton ID="ImageButton2" runat="server" BorderStyle="None" CommandName="img_click" ImageUrl="~/but_img/cross.png" AlternateText="删除" />
<cc1:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="ImageButton2" ConfirmText='<%# Alert.Del_info() %>'>
</cc1:ConfirmButtonExtender>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
怎样获得 CommandName="img_click" ?
<asp:ImageButton ID="ImageButton2" runat="server" BorderStyle="None" CommandName="img_click" ImageUrl="~/but_img/cross.png" AlternateText="删除" />
你需要在哪里找这个控件?举两个例子,相关数据可以忽略~
ItemDataBound事件中查找控件:
<asp:HyperLink ID="HLinkModify" NavigateUrl='<%# "Admin_User.aspx?id="+Eval("id")%>' Target="_self" runat="server">点击修改</asp:HyperLink>
protected void RptUser_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.SelectedItem)
{
DataRowView rowv = (DataRowView)e.Item.DataItem;
if (rowv["username"].ToString() != Session["admin"].ToString())
{
HyperLink HLinkModify = (HyperLink)e.Item.FindControl("HLinkModify");
HLinkModify.Visible = false;
}
}
}
Rpt中控件的事件使用:
<asp:LinkButton ID="LBtnDel" OnClick="LBtnDel_OnClick" ToolTip='<%# Eval("username") %>' runat="server">删除</asp:LinkButton>
//Rpt中控件的事件
protected void LBtnDel_OnClick(object sender,EventArgs e)
{
LinkButton LBtnDel = sender as LinkButton;//触发事件的LinkButton
//RepeaterItem item = LBtnDel.NamingContainer as RepeaterItem; //LinkButton所在行
string username = LBtnDel.ToolTip.ToString();
...
}