日期:2014-05-18  浏览次数:20363 次

gridview中linkbutton的事件
在gridview中有一列中用linkbutton控件做了超链接,我想每次点击超链接触发一个事件,好更新数据库中一个数值,如下
Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
  if e.CommandName ="link" then
  。。。
  End If
end sub



<asp:TemplateField ><ItemTemplate>
  <asp:LinkButton ID="LinkButton1" runat="server" CommandName ="link" CausesValidation="false" CommandArgument ='<%#Eval("bblink") %>' OnClick ="LinkButton1_Click" Text='<%eval("bbid") %>' PostBackUrl=“......” >下载...</asp:LinkButton>
</ItemTemplate> </asp:TemplateField>
但是怎么也不能激发rowcommand事件,如果换成
<asp:ButtonField Text="按钮" CommandName ="link" />就能激发rowcommand事件,但是又能实现超链接,请问为什么,我搜了baidu好长时间都不能解决,谢谢了

------解决方案--------------------
PostBackUrl="........"
这里跳转了~so 没有执行GridView1_RowCommand