在Repeater中ItemTemplate添加了一个LinkButton:
<tr>
<td><%# Eval("ItemID") %></td>
<td><%# Eval("ItemName") %></td>
<td><asp:linkbutton id="LinkButton1" runat="server" commandname="LinkButton1" text="LinkButton1" /></td>
</tr>在Repeater的ItemCreated事件中反问每个项中的LinkButton的ClientID:
protected void Repeater1_ItemCreated(object sender, RepeaterItemEventArgs e)
{
Button btn1 = e.Item.FindControl( "Button1" ) as Button;
if (btn1 != null)
{
// do nothing, just to access the ClientID owing to the button
//
string temp = btn1.ClientID;
} LinkButton lnkbtn1 = e.Item.FindControl( "LinkButton1" ) as LinkButton;
if (lnkbtn1 != null)
{
// do nothing, just to access the ClientID owing to the linkbutton
//
string temp = lnkbtn1.ClientID;
}
}结果, LinkButton不会激发Repeater的ItemCommand事件了。
但是,只要将 string temp = lnkbtn1.ClientID; 这句注销掉就可以了。
Why?详细信息请大家看:http://jinglecat.cnblogs.com/archive/2006/05/12/398335.html,有详细源码
<tr>
<td><%# Eval("ItemID") %></td>
<td><%# Eval("ItemName") %></td>
<td><asp:linkbutton id="LinkButton1" runat="server" commandname="LinkButton1" text="LinkButton1" /></td>
</tr>在Repeater的ItemCreated事件中反问每个项中的LinkButton的ClientID:
protected void Repeater1_ItemCreated(object sender, RepeaterItemEventArgs e)
{
Button btn1 = e.Item.FindControl( "Button1" ) as Button;
if (btn1 != null)
{
// do nothing, just to access the ClientID owing to the button
//
string temp = btn1.ClientID;
} LinkButton lnkbtn1 = e.Item.FindControl( "LinkButton1" ) as LinkButton;
if (lnkbtn1 != null)
{
// do nothing, just to access the ClientID owing to the linkbutton
//
string temp = lnkbtn1.ClientID;
}
}结果, LinkButton不会激发Repeater的ItemCommand事件了。
但是,只要将 string temp = lnkbtn1.ClientID; 这句注销掉就可以了。
Why?详细信息请大家看:http://jinglecat.cnblogs.com/archive/2006/05/12/398335.html,有详细源码
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货