<asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False" Width="100%" ForeColor="Black" OnItemCommand="item_command" BorderColor="#999999"> <Columns> <asp:TemplateColumn HeaderText="堆叠"> <ItemTemplate> <asp:ImageButton ID="Imagebutton4" Runat="server" CommandName="Item_dd" ImageUrl="../../images/find.gif"></asp:ImageButton> </ItemTemplate> </asp:TemplateColumn> ......'代码 Sub item_Command(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Select Case (CType(e.CommandSource, ImageButton)).CommandName Case "Item_dd" Dim yy = CType(e.Item.FindControl("bh"), Label).Text Response.Write("<script>window.open('dd_qk.aspx?yy=" + yy + "','yy','toolbar=no,resizable=yes,width=650,height=380')</script>") fillgrid() Case Else ' Do nothing. End Select End Sub
'忘了判断,修改如下,你还要自己修改一下 Sub item_Command(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Select Case (CType(e.CommandSource, ImageButton)).CommandName Case "Item_dd" if CType(e.Item.FindControl("要判断的字段"), Label).Text Dim yy = CType(e.Item.FindControl("bh"), Label).Text Response.Write("<script>window.open('dd_qk.aspx?yy=" + yy + "','yy','toolbar=no,resizable=yes,width=650,height=380')</script>") fillgrid() end if Case Else ' Do nothing. End Select End Sub
<asp:TemplateColumn HeaderText="堆叠"> <ItemTemplate>
<asp:ImageButton ID="Imagebutton4" Runat="server" CommandName="Item_dd" ImageUrl="../../images/find.gif"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
......'代码
Sub item_Command(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Select Case (CType(e.CommandSource, ImageButton)).CommandName
Case "Item_dd"
Dim yy = CType(e.Item.FindControl("bh"), Label).Text
Response.Write("<script>window.open('dd_qk.aspx?yy=" + yy + "','yy','toolbar=no,resizable=yes,width=650,height=380')</script>")
fillgrid()
Case Else
' Do nothing. End Select End Sub
Sub item_Command(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Select Case (CType(e.CommandSource, ImageButton)).CommandName
Case "Item_dd"
if CType(e.Item.FindControl("要判断的字段"), Label).Text
Dim yy = CType(e.Item.FindControl("bh"), Label).Text
Response.Write("<script>window.open('dd_qk.aspx?yy=" + yy + "','yy','toolbar=no,resizable=yes,width=650,height=380')</script>")
fillgrid()
end if
Case Else
' Do nothing. End Select End Sub